本帖最后由 subendong 于 2012-05-22 11:50:07 编辑

解决方案 »

  1.   


    //需检查权限的页面
    public partial class Questions : MyPage
    {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    ((SiteMaster)this.Master).CheckPermition(OES2.MyAccount.AccountRole.教师, "", 6);
                }
            }
    }
    //模板页
    public void CheckPermition(MyAccount.AccountRole BaseRole,string Title,int selectedIndex)
            {
                ShowTitle(Title,selectedIndex);
                if (BaseRole == MyAccount.AccountRole.未定义)
                {
                    MainContent.Visible = true;
                    HasErr = false;
                    ErrorState = "";
                    if (MyAccount.IsAccessed(Common.AccountSession, MyAccount.AccountRole.登录用户))
                    {
                        div_unreged.Style.Add(HtmlTextWriterStyle.Display, "none");
                        div_reged.Style.Add(HtmlTextWriterStyle.Display, "inline");
                    }
                    else
                    {
                        div_unreged.Style.Add(HtmlTextWriterStyle.Display, "inline");
                        div_reged.Style.Add(HtmlTextWriterStyle.Display, "none");
                    }
                }
                else
                {
                    if (MyAccount.IsAccessed(Common.AccountSession, BaseRole))
                    {
                        MainContent.Visible = true;
                        HasErr = false;
                        ErrorState = "";
                        div_unreged.Style.Add(HtmlTextWriterStyle.Display, "none");
                        div_reged.Style.Add(HtmlTextWriterStyle.Display, "inline");
                    }
                    else
                    {
                        MainContent.Visible = false;
                        HasErr = true;
                        ErrorState = "-1";
                        div_unreged.Style.Add(HtmlTextWriterStyle.Display, "inline");
                        div_reged.Style.Add(HtmlTextWriterStyle.Display, "none");
                    }
                }
            }
    这是我做的权限检查。
      

  2.   

    OnInit 里进行控制 足以