473,480 Members | 2,057 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 3334
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
3624
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
650
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
3329
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
3994
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
1714
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
1003
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
1809
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
4037
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
1632
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,...
0
6911
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7050
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7091
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5344
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4488
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2999
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2988
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
564
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.