![]() |
How can I prevent a button event firing on page refresh?
If a page has a button with event handler
private void btnAdd_Click(object sender, System.EventArgs e) { ....... } this event handler fires every time I refresh the page in the browser with F5 AFTER the button was clicked. So the pages loads the first time. clicking F5 does normal postback and refresh Add button clicked, btn_Add_Click is called Now if I click F5 btn_AddClick is called again... If there two buttons on the page, whichever was clicked last will be executed again on F5. How can I stop it? Thanks, -Stan |
Re: How can I prevent a button event firing on page refresh?
Skip smart navigation. It only sometimes works.
Put information about the type of event fired into the session object when the event fires the first time. In the same event handler read this value from the session if it differes then it means that you've clicked a different button and you should run the event. If it doesn't then it means you've clicked on the same button two times and that you should ignore the event. Works good, assuming that you don't want to fire the same event in concession. "Stan" <nospam@yahoo.com> wrote in message news:eMZjMkOPDHA.3144@tk2msftngp13.phx.gbl... > If a page has a button with event handler > > private void btnAdd_Click(object sender, System.EventArgs e) > { > ...... > } > > this event handler fires every time I refresh the page in the browser with > F5 AFTER > the button was clicked. > > So the pages loads the first time. > clicking F5 does normal postback and refresh > Add button clicked, btn_Add_Click is called > Now if I click F5 btn_AddClick is called again... > > If there two buttons on the page, whichever was clicked last will be > executed again on F5. > > How can I stop it? > > Thanks, > > -Stan > > > > > > |
| All times are GMT. The time now is 06:17 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.