Why in ASP.NET is a button click event executes wh

2020-02-05 02:03发布

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.

标签: asp.net
7条回答
家丑人穷心不美
2楼-- · 2020-02-05 02:45

If I understand correctly.

You have a web form with a button.

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.

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.

查看更多
登录 后发表回答