JBTALKS.CC

标题: asp.net 问题 [打印本页]

作者: 我是大猪头    时间: 2009-11-8 07:11 PM
标题: asp.net 问题
能弄到指定的某个role不能view哪一个node不过却弄不到当session没资料的时候
                SiteMapNode mapNode = (SiteMapNode)e.Item.DataItem;
                SiteMapNode mapNode1 = (SiteMapNode)e.Item.DataItem;

                string sUserRole = Session["UserRole"].ToString();

                if(sUserRole == "Staff")
                {
                    if (mapNode.Description == "ManagerAndAdmin")
                    {
                        MenuItem muItemParent = e.Item.Parent;

                        muItemParent.ChildItems.Remove(e.Item);
                    }
                }
                else if (sUserRole == "")
                {

                    if (mapNode1.Description == "AllRole")
                    {
                        MenuItem muItemParent = e.Item.Parent;

                        muItemParent.ChildItems.Remove(e.Item);
                    }                    
                }
请goodday哥赐教了

[ 本帖最后由 我是大猪头 于 2009-11-8 07:12 PM 编辑 ]
作者: goodday    时间: 2009-11-8 08:02 PM
if(Session["UserRole"]== null)
{

}
作者: 我是大猪头    时间: 2009-11-8 09:14 PM
原帖由 goodday 于 2009-11-8 08:02 PM 发表
if(Session["UserRole"]== null)
{

}



一开始就试过了。。这个方法不行
作者: AhPang    时间: 2009-11-8 09:21 PM
这个呢?
if(String.IsNullOrEmpty(sUserRole))
作者: 我是大猪头    时间: 2009-11-8 09:37 PM
做到了
感谢各位
作者: goodday    时间: 2009-11-8 09:38 PM
肯定能的

null 和 string.emptyornull 有分别的
send 你的 code  给我




欢迎光临 JBTALKS.CC (https://jbtalks.my/) Powered by Discuz! X2.5