Page_Load事件会在第一次加载页面时发生和将该页面回发到服务器时发生

第一种情况Page.IsPostBack返回false,第二种返回True。

若在Page_Load事件中有一些对控件的操作,比如

txtName.Text = name;
txtAuthor.Text = author;
txtCount.Text = count;

 

在另一个事件中也有类似的

string amend_name = txtName.Text;
string amend_author = txtAuthor.Text;
string amend_count = txtCount.Text;

 

此时这一事件发生amend_name的值不为TextBook中更改过的值,而为原先name的值,因为Page_Load事件也会发生。

所以,若要使得Page_Load事件只在第一次加载页面时发生可使用

if(!IsPostBack)

{

}

 

相关文章:

  • 2021-10-07
  • 2022-12-23
  • 2021-10-29
  • 2022-02-11
  • 2022-01-01
  • 2022-12-23
  • 2022-02-22
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-28
  • 2022-12-23
  • 2021-08-23
  • 2021-12-19
  • 2022-12-23
相关资源
相似解决方案