为什么在ASP.NET页面被刷新时,一个按钮单击事件执行? [英] Why in ASP.NET is a button click event executes when page is refreshed?
问题描述
在我的ASP.Net网站我有一个button.When我按一下按钮,然后通过浏览器重新载入页面,按钮fires.Where的单击事件是一个问题,请大家帮帮我。
In my ASP.Net Web Site I have a button.When I click the button and then reload the page via browser,the click event of the button fires.Where is a problem,please help me.
推荐答案
如果我理解正确。
您有一个按钮Web表单。
You have a web form with a button.
你推这将导致一个回按钮,该按钮preSS执行事件处理程序。
You push the button which causes a post back and the event handler for the button press to execute.
然后你打刷新页面有该按钮的事件处理程序再执行。
Then you hit refresh and the page has the button event handler execute again.
这样做的原因是您的清爽发送到服务器的最后信息。这是在__doPostBack按钮点击信息。这就是为什么你又可以看到该按钮一旦发生火灾。
The reason for this is your refreshing the last information sent to the server. Which is the button click information in the __doPostback. This is why you are seeing the event of the button fire again.
下面是一个文章,谈到如何在回发检测刷新。
Here is an article talking about how to detect a refresh over a postback.
这篇关于为什么在ASP.NET页面被刷新时,一个按钮单击事件执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!