按钮单击事件之前运行的页面加载事件 [英] Page load event running prior to button click event

查看:84
本文介绍了按钮单击事件之前运行的页面加载事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在为用户创建一个包含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

推荐答案

Quote:

页面加载事件在按钮单击事件之前运行

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆