473,602 Members | 2,811 Online
Bytes | Software Development & Data Engineering Community
+ 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_Cl ick(object sender, System.Web.UI.I mageClickEventA rgs e)
{
//some code
}

Set break point on private void ImageButton1_Cl ick

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

Test2: type some text in textbox and click image button.
Result: private void ImageButton1_Cl ick 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_Cl ick will trigger.

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

Nov 18 '05 #1
1 3351
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*******@disc ussions.microso ft.com> wrote in message
news:2A******** *************** ***********@mic rosoft.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_Cl ick(object sender, System.Web.UI.I mageClickEventA rgs e) {
//some code
}

Set break point on private void ImageButton1_Cl ick

Test1: Hit page refresh button on IE
Result: nothing will happen ( I mean private void ImageButton1_Cl ick will not trigger)
Test2: type some text in textbox and click image button.
Result: private void ImageButton1_Cl ick 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_Cl ick will trigger.

Why ? I want to have private void ImageButton1_Cl ick 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
3631
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 am trying to do. The ImageButton that is on the form handles its Command event just fine, but the ImageButton that is added to the cell does not handle the event. Am I doing something wrong, or is not possible to add server controls to a calendar...
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 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...
1
3336
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 ImageClickEventHandler(this.save_click); This ImageButton is added to a dynamic table which is also
2
4000
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 find an answer for any where on the net. Any help in the right direction would be greatly appreciated. If more code/source is need please let me know and I will post more.
3
1724
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: The window in question is a popup asking the user to provide some details. The primary window is still open in the background 1. Button on popup clicked
1
1006
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 being fired, that event is not called from any part of my code, just when the user clicks the button. The button´s only property that I have changed is the causes valudation property set to FALSE. This is using VS.NET 2005
0
1819
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, everything works okay. I can press <ENTER> when the cursor is inside the text box and the page is running, and no events fire (this is what I expect). But as soon as I drop a second text box on the page (ie: after th first one) then pressing...
1
4052
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 IE all is ok, under Firefox no, it seems that the click event isn't raised when I click on the ImageButton. any idea ?
1
1638
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, absolutely nothing happens when I click it. Does anyone know if this could have anything to do the fact that my button is on a master page (along with the handler)? That shouldn't make any difference should it?
0
7920
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8404
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8268
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
3900
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2418
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 we have to send another system
1
1510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1254
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.