C#中ISpostback

響應客戶端控件時ispostback爲true

代碼:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class DateShow : System.Web.UI.Page
{
    string date;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (date == null)
        {
            date = DateTime.Now.ToString();
        }
        Response.Write("當前時間:"+ date);
        if (!IsPostBack)
        {
            Response.Write("第一次加載!");
        }
        else
        {
            Response.Write("響應客戶端請求加載");
        }
    }
}

  刷新結果爲第一次加載

     點擊button結果爲響應客戶端請求加載。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章