调试Page.IsPostBack,感觉好奇怪

public partial class _Default : System.Web.UI.Page
{
    private string msgStr="";
    private string _IsPostBack = "false";
    protected void Page_Load(Object obj,EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (_IsPostBack != "OK")
            {
                _IsPostBack = "true";
            }
            msgStr = "NotPostBack" + DateTime.Now;
            msg.Text = msgStr+":"+_IsPostBack;          //打开页面后,查看两句的结果;2、刷新页面,查看结果;我感觉有点奇怪
            if (_IsPostBack == "true")
            {
                News_ClassDAL nc = new News_ClassDAL();
                News_ClassInfo ncData = new News_ClassInfo();
                List<News_ClassInfo> list = new List<News_ClassInfo>();
                list = nc.GetListArray("");
                gv.DataSource = list;
                gv.DataBind();
                _IsPostBack = "OK";
                msgStr = "loading data";
            }
            msg1.Text = msgStr + ":" + _IsPostBack;
        }
        else
        {
            msgStr = "IsPostBack"+ DateTime.Now;
            News_ClassDAL nc = new News_ClassDAL();
            News_ClassInfo ncData = new News_ClassInfo();
            List<News_ClassInfo> list = new List<News_ClassInfo>();
            list = nc.GetListArray("");
            gv.DataSource = list;
            gv.DataBind();
            msg1.Text = msgStr + ":" + _IsPostBack;
        }
    }
}

posted @ 2013-01-10 15:32  xyzyyj  阅读(234)  评论(0编辑  收藏  举报