Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# asp.net显示不同的用户登录信息_C#_Asp.net_Html - Fatal编程技术网

C# asp.net显示不同的用户登录信息

C# asp.net显示不同的用户登录信息,c#,asp.net,html,C#,Asp.net,Html,我是这里的新手,有没有办法在w3 col s8 w3栏上显示不同的用户登录信息 我把它固定在母版页和侧边栏上,我需要一些帮助。 只有管理员登录才是正确的信息,因为我已将其修复, 如果Bob登录将显示“管理员”,而不是Bob信息 谢谢 <nav class="w3-sidebar w3-collapse w3-white w3-animate-left" style="z-index:3;width:300px;" id="mySidebar"><br/> &

我是这里的新手,有没有办法在w3 col s8 w3栏上显示不同的用户登录信息

我把它固定在母版页和侧边栏上,我需要一些帮助。 只有管理员登录才是正确的信息,因为我已将其修复, 如果Bob登录将显示“管理员”,而不是Bob信息

谢谢

     <nav class="w3-sidebar w3-collapse w3-white w3-animate-left" style="z-index:3;width:300px;" id="mySidebar"><br/>
  <div class="w3-container w3-row">
    <div class="w3-col s4">
      <img src="/images/logo.png" class="w3-circle w3-margin-right" style="width:46px"/>
    </div>
    <div class="w3-col s8 w3-bar">
      <span>Welcome, <strong>Administrator</strong></span><br/>
 <a><asp:LinkButton class="w3-button w3-red w3-padding-small" runat="server" OnClick="Logout" Text="logout"></asp:LinkButton></a> 
<div class="w3-bar-block">
    <a href="#" class="w3-bar-item w3-button w3-padding-16 w3-hide-large w3-dark-grey w3-hover-black" onclick="w3_close()" title="close menu"><i class="fa fa-remove fa-fw"></i>Close Menu</a>
    <a href="FORMS/Stationary/Stationary.aspx" class="w3-bar-item w3-button w3-padding"><i class="fa fa-user"></i> Stationary</a>
    <a href="FORMS/Books/Books.aspx" class="w3-bar-item w3-button w3-padding"><i class="fa fa-pencil-square-o"></i>Books</a>
  </div>
</nav>

欢迎,管理员

如果我是对的,您正试图根据登录的用户显示不同的信息

如果您使用identity,您可以这样写:

如果您只需要显示用户名

<span>Welcome, <strong>@User.Identity.Name</strong></span>
欢迎,@User.Identity.Name
如果需要检查登录的用户

@if(User.Identity.Name.Equals("Administrator"))
{
    <span>Welcome, <strong>Administrator</strong></span>
}
else if(User.Identity.Name.Equals("Bob"))
{
    <span>Welcome, <strong>Bob</strong></span>
}
@if(User.Identity.Name.Equals(“管理员”))
{
欢迎,管理员
}
else if(User.Identity.Name.Equals(“Bob”))
{
欢迎,Bob
}
如果你有一些角色,你可以这样检查

@if(User.IsInRole("Administrator"))
{
    <span>Welcome, <strong>Administrator</strong></span>
}
else 
{
    <span>Welcome, <strong>User</strong></span>
}
@if(User.IsInRole(“管理员”))
{
欢迎,管理员
}
其他的
{
欢迎,用户
}

如果您希望管理员更改为其他用户,则只需将其设置为变量并将其分配给该范围。。。发一些代码什么?我不知道你在问什么。请把你的问题重新表述清楚。此外,如果您不发布任何代码,也很难为您提供帮助。@A GrammerPro我必须更新问题。@sumeet kumar代码更新您想要更改的内容?您是否有母版页而不是mvc的方式?