按钮单击事件之前运行的页面加载事件 [英] Page load event running prior to button click event
问题描述
大家好,
我正在为用户创建一个包含3个操作的网页:
1 。用户从下拉列表中选择ID。相关数据显示在下面的文本框中。
2.用户在文本框中进行更改。
3.用户单击保存按钮更新数据库中的更改。
问题是当用户单击保存按钮时,页面加载事件在按钮单击事件基于下拉列表选择重新加载数据之前运行,并在过程中从文本框中删除所有更改的元素。
请参阅指南。谢谢
Hi All,
I am creating a webpage with 3 actions for users:
1. Id is selected by user from drop down list. The related data is shown in text boxes below.
2. User makes changes in the text boxes.
3. User clicks Save button to update the changes in database.
Problem is when the user clicks Save button, the Page load event runs before the button click event reloading the data based on dropdownlist selection and in process removing all changed elements from text boxes.
Pls guide. Thanks
推荐答案
页面加载事件在按钮单击事件之前运行
Page load event runs before the button click event
按照设计,阅读 ASP .NET应用程序和页面生命周期 [ ^ ]
和 ASP.NET页面生命周期概述 [ ^ ]
As designed, read ASP.NET Application and Page Life Cycle[^]
And ASP.NET Page Life Cycle Overview [^]
按钮单击事件根据下拉列表选择重新加载数据,并在过程中从文本框中删除所有更改的元素。
the button click event reloading the data based on dropdownlist selection and in process removing all changed elements from text boxes.
Don't bind data on postback[^]
in page load event, do as below
if(!IsPostBack)
{
// here bind the data to your controls like gridviews drop down lists
}
这篇关于按钮单击事件之前运行的页面加载事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!