Page.IsPostBack 是什么作用?
我现在做一个程序,如果程序没有按正常登录,就让他返回首页,出现了两种方法:
这是我的方法:
if (!Page.IsPostBack)
{
if (Session["flag"] == null || Session["flag"].ToString() != "ok")
{
Response.Redirect("../Login.aspx");
}
DataLoad();
}
这是我见到的方法:
if (Session["flag"] == null || Session["flag"].ToString() != "ok")
{
Response.Redirect("../Login.aspx");
}
if (!Page.IsPostBack)
{
DataLoad();
}
请问有什么区别 ?