码迷,mamicode.com
首页 > Windows程序 > 详细

【原创】如何编写c#用户登陆后用户名在前台显示

时间:2017-01-20 10:55:12      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:编写   amp   gis   用户   out   blog   sid   type   pre   

 

这种肯定是判断session啦!!!!!

@{
    string username = (string)Session["username"];
    user user = new user();
    if (username != null && username.Length > 0)
    {
        user = (user)Session["user"];
    }
}

  在页面中就这样写

   @{

    int isLogin = 0;
    if (username != null && username.Length > 0)
    {
        isLogin = 1;

        if (user.type == 1)
        {
            <span class="gr-title"><b></b>@username</span>
            <div class="sidemenu">
                <a href="/Fastorders/myFastorderList?userID=@user.id" class="">我的订单</a>
                <a href="/user/logout">退出当前帐号</a>
            </div>
        }
        else
        {
            <span class="gs-title"><b></b>@username</span>
            <div class="sidemenu">
                <a href="/Fastorders/myFastorderList?userID=@user.id" class="">单位订单</a>
                <a href="/user/logout">退出当前帐号</a>
            </div>
        }
    }
    else
    {
        <span style="padding-left: 30px;background: url(/images/index/index-login.png) no-repeat 5px center;"></span>
        <a href="/user/login" style="margin-right:15px;">登录</a><a href="/user/register">注册</a>
    }
}

  

【原创】如何编写c#用户登陆后用户名在前台显示

标签:编写   amp   gis   用户   out   blog   sid   type   pre   

原文地址:http://www.cnblogs.com/wanghaiyang/p/6322126.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!