首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

未将对象引用设立到对象的实例&当前上下文不存在名称

2013-04-21 
未将对象引用设置到对象的实例&当前上下文不存在名称不加if (Session[MyForbid] ! null)这一句,提示未

未将对象引用设置到对象的实例&当前上下文不存在名称
不加if (Session["MyForbid"] != null)这一句,
提示未将对象引用设置到对象的实例,加上提示当前上下文不存在名称“MyForbidString”

public partial class System_CompanyForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       if (Session["MyForbid"] != null)
     {
            string MyForbidString = Session["MyForbid"].ToString();
  }
  if (MyForbidString.IndexOf("E2") > 1)
  {
      Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
  }
    }
错误1当前上下文中不存在名称“MyForbidString”(红色的)

麻烦高手帮忙看看,O(∩_∩)O谢谢
[解决办法]



       if (Session["MyForbid"] != null)
     {
            string MyForbidString = Session["MyForbid"].ToString();
if (MyForbidString.IndexOf("E2") > 1)
  {
      Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
  }
  }
  

[解决办法]
public partial class System_CompanyForm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
       if (Session["MyForbid"] != null)
       {
            string MyForbidString = Session["MyForbid"].ToString();
  
           if (MyForbidString.IndexOf("E2") > 1)
           {
                 Server.Transfer("~/SystemManage/AllErrorHelp.aspx");
           }
    }

热点排行