By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,512 Members | 3,790 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,512 IT Pros & Developers. It's quick & easy.

ImageButton problem with page refresh

P: n/a
Problem
I have a problem with web image button control click event. The click event does not get trigger until it has not been clicked once or page refresh occures(which is fine).

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..
My 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)
{
//some code
}

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 textbox and click image button.
Result: private void ImageButton1_Click will trigger and it will stop at break point.
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.

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

Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
this is by design. in the test 3 case, the browser knows the render was a
result of a form post. to refresh the page, it needs to resubmit the post
data (normally it alters you to this). to the server this looks no different
than the orignal post.

-- bruce (sqlwork.com)

"ppatel" <an*******@discussions.microsoft.com> wrote in message
news:2A**********************************@microsof t.com...
Problem:
I have a problem with web image button control click event. The click event does not get trigger until it has not been clicked once or page
refresh occures(which is fine).
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...

My 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) {
//some code
}

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 textbox and click image button.
Result: private void ImageButton1_Click will trigger and it will stop at break point. 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.

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

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.