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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Brijendra GautamPosted Apr 6, 2014, 7:43 AM
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.loginview%28v=vs.110%29.aspx
Khan Abrar AhmedPosted Apr 6, 2014, 7:28 AM
did you crete the "UserName" property on the page or from some object you want to compare.
if (UserName == "firoz")
{
Button2.Visible = false;
}
else
{
Button2.Visible = true;
}
Ans:
Private string UserName="firoz";
protected void Page_Load(object sender, EventArgs e)
{
if (UserName == "firoz")
{
Button2.Visible = false;
}
else
{
Button2.Visible = true;
}
}
Hope this will help
Firoz KhanPosted Apr 6, 2014, 7:21 AM
protected void Page_Load(object sender, EventArgs e)
{
if (UserName == "firoz")
{
Button2.Visible = false;
}
else
{
Button2.Visible = true;
}
}
what i need to do now plz......suggest me...
Khan Abrar AhmedPosted Apr 6, 2014, 6:57 AM
C# :
if(UserName == "USER_123")
{
dvAccess.Attributes.add["style"]="display:block;";
}
else
{
dvAccess.Attributes.add["style"]="display:none;";
}
Ganesh SingaraveluPosted Apr 5, 2014, 9:56 AM
C# :
if(User_Name == "Ganesh")
{
Div_Ex.Attributes.CssStyle[HtmlTextWriterStyle.Visibility] = "hidden";
}
else
{
Div_Ex.Attributes.CssStyle[HtmlTextWriterStyle.Visibility] = "visible";
}
Use this Code. It will help you.