Previous(Unwanted) event handled when page refreshed by key F5

  • Thread starter sanjay patil via .NET 247
  • Start date
S

sanjay patil via .NET 247

Hello,
I have a problem with web image button control click event. I am saving a record to database on click event of this image button.

When click event fires first time it executes code associate with click event(As I expected). The problem is when you refresh page it fires a click event automatically.

I looked around many posts and did not find any topics about this problem. Infact the same behavior occured for regular web button control click event too.

Any ideas...



Test Example:
Let say you have webproject and page name is WebForm1

Drop one textbox control and one imagebox control on webpage form

Double click on Imagebox control.

It will create following event

private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
//Code for saving a record
}

Set break point on private void ImageButton1_Click

Test1: Hit page refresh button on IE
Result: nothing will happen ( I mean private void ImageButton1_Click will not trigger)

Test2: type some text in textboxes and click image button.
Result: private void ImageButton1_Click will trigger and it will Save that record.
Hit Debug->Continue again

Test3: do not do any thing after Test2. Just hit page refresh button on IE
Result: private void ImageButton1_Click will trigger. And that record get saved again.

Why ? I want to have private void ImageButton1_Click occure only when Imagebutton click occurs not on page refresh.


Thanx and Regards,
Sanjay.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top