if (Session["USERNAME"] == null)
{
(this.MultiView1.FindControl("View1") as MultiView).ActiveViewIndex = 0;
}
else
{
(this.MultiView1.FindControl("View2") as MultiView).ActiveViewIndex = 1;
this.name.Text = Session["USERNAME"].ToString();
}
网页打开一加载就判断SESSION值是否为空,吥空就显示View1这个,空就显示View2。。。
------解决方案--------------------------------------------------------
if (Session["USERNAME"] == null)
{
MultiView1.ActiveViewIndex = 0;
}
else
{
MultiView1.ActiveViewIndex = 1;
this.name.Text = Session["USERNAME"].ToString();
}
------解决方案--------------------------------------------------------
不光要判断Session是否为空,还要判断转换以后的控件是否为空,打断点可以找到,如果是控件为Null,则要检查你的FindControl是否有问题了