根据C#中记录的用户名显示隐藏div [英] show hide div based on logged user name in C#

查看:81
本文介绍了根据C#中记录的用户名显示隐藏div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





i我在asp.net开发一个网站,我想根据用户名显示/隐藏div。



示例:



如果用户已登录且用户名为USER_123则显示此div否则隐藏此div。







问候



firoz khan

解决方案

尝试

 function ShowHideDiv(obj)
{
if (document.getElementById(userName)== ' USER _!@#'
{
var dataDiv = document.getElementById(obj);
dataDiv.style.display = block;
}
}


如果用户无权查看该div中的某些信息,那么它不应出现在甚至它被隐藏的页面。您应该将他重定向到包含他有权查看的信息的页面。换句话说,您应该根据角色为不同的用户创建单独的页面。建议你阅读:演练:管理带角色的网站用户 [ ^

Hi,

i am developing a website in asp.net, i want to show/Hide div based on user name.

Example:

If user is logged in and user name is USER_123 show this div else hide this div.



regards

firoz khan

解决方案

Try

function ShowHideDiv(obj)
{
     if (document.getElementById(userName) == 'USER_!@#')
{  
     var dataDiv = document.getElementById(obj);
     dataDiv.style.display = "block";
}
}


If the user is not authorized to view certain information in that div, then it should not be present in the page at all even it is hidden. You should instead redirecting him to some page that contains information that he is authorized to see. In other words, you should create separate pages for different users based on their roles. Suggest you read this: Walkthrough: Managing Web Site Users with Roles[^]


这篇关于根据C#中记录的用户名显示隐藏div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆