读书人

未将对象引用设立到对象的实例amp;当前上

发布时间: 2013-04-21 21:18:07 作者: rapoo

未将对象引用设置到对象的实例&当前上下文不存在名称
不加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");
}
}

读书人网 >asp.net

热点推荐