473,289 Members | 1,875 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

ImageButton problem with page refresh

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
1 3320
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chuck Hartman | last post by:
I've been trying to add an ImageButton object to a Calendar table cell, but so far I am unable to handle the Command event from that button in my form's code behind. Below is an example of what I...
1
by: ppatel | last post by:
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...
1
by: Henke | last post by:
Hello, I have one ImageButton controls which I initialize in Page_Load and declare on class level. ImageButton save = new ImageButton(); save.ImageUrl = "save.gif" save.Click += new...
2
by: CJ Oakwood | last post by:
Morning - I am hoping somebody from this group can help me out here... I have been trying to add an array of ImageButtons to my WebForm however I keep getting an exception that I can't seem to...
3
by: thechaosengine | last post by:
Hi all, I need to be able to cause the following chain of events after clicking an asp:button but I don't know how to do it. I'd really appreciate any advice on this or alternative approaches: ...
1
by: TCORDON | last post by:
I have a web page that has a ImageButton that changes the value o a session variable. The problem is that when I click the refresh button in my browser somehow the click event for that button is...
0
by: Tom Edelbrok | last post by:
I'm using VS 2005 to develop an intranet asp.net web application and I get a weird situation. If I start out with any ASPX page that contains an ImageButton control followed by a TextBox control,...
1
by: RicercatoreSbadato | last post by:
i need help, i have an ImageButton inside the ItemTemplate tag of a Repeater. In the code behind i use a DataBound() to assign a CommandName and a CommandArgument to the ImageButton. If i use...
1
by: Jonathan Wood | last post by:
I'm trying to convert some old HTML pages to ASP.NET. I'm experimenting with code that responds to a button click. But although the mouse turns into a hand pointer when it is over the button,...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.