ImageButton Server-side OnClick handler doesn't always get called
-
I have a server-side ImageButton:
<asp:ImageButton id="btnDoSomething" runat="server" StartContainer="maindirection" 0nClick="StartProcessButtonClick" AlternateText="Start process" ImageUrl="/public/buttonImage.jpg" />
(note I've changed the O in OnClick to a zero so this post displays correctly). The button has the appropriate code-behind:protected void StartProcessButtonClick(object sender, ImageClickEventArgs e) { if(sender is ImageButton) { // blah } }
This button works for 95% of the visitors to the site, but for a select few, it the server-side handler doesn't get called. It's absolutely consistent - it either works on a PC, or doesn't, but there's no logical pattern as to why it doesn't work. Any ideas at all why the handler would get called for one client (running IE6 SP2) but not for another (same browser)??!!?!? :doh: ________________________ http://www.webreaper.net -- modified at 12:04 Wednesday 3rd May, 2006 -
I have a server-side ImageButton:
<asp:ImageButton id="btnDoSomething" runat="server" StartContainer="maindirection" 0nClick="StartProcessButtonClick" AlternateText="Start process" ImageUrl="/public/buttonImage.jpg" />
(note I've changed the O in OnClick to a zero so this post displays correctly). The button has the appropriate code-behind:protected void StartProcessButtonClick(object sender, ImageClickEventArgs e) { if(sender is ImageButton) { // blah } }
This button works for 95% of the visitors to the site, but for a select few, it the server-side handler doesn't get called. It's absolutely consistent - it either works on a PC, or doesn't, but there's no logical pattern as to why it doesn't work. Any ideas at all why the handler would get called for one client (running IE6 SP2) but not for another (same browser)??!!?!? :doh: ________________________ http://www.webreaper.net -- modified at 12:04 Wednesday 3rd May, 2006Do other server controls work on the machines where this doesn't? Do the machines where it doesn't work have javascript disabled? Current blacklist svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
-
Do other server controls work on the machines where this doesn't? Do the machines where it doesn't work have javascript disabled? Current blacklist svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
Javascript is enabled, as are cookies, etc. We have lots of other code running on that machine (we've got a development machine which the problem happens on, but all our other sites work on that machine). It also comes and goes - I've had the problem on my development machine one day, and then a couple of hours later it stops happening and the site works correctly. It's most bizarre! ________________________ http://www.webreaper.net
-
I have a server-side ImageButton:
<asp:ImageButton id="btnDoSomething" runat="server" StartContainer="maindirection" 0nClick="StartProcessButtonClick" AlternateText="Start process" ImageUrl="/public/buttonImage.jpg" />
(note I've changed the O in OnClick to a zero so this post displays correctly). The button has the appropriate code-behind:protected void StartProcessButtonClick(object sender, ImageClickEventArgs e) { if(sender is ImageButton) { // blah } }
This button works for 95% of the visitors to the site, but for a select few, it the server-side handler doesn't get called. It's absolutely consistent - it either works on a PC, or doesn't, but there's no logical pattern as to why it doesn't work. Any ideas at all why the handler would get called for one client (running IE6 SP2) but not for another (same browser)??!!?!? :doh: ________________________ http://www.webreaper.net -- modified at 12:04 Wednesday 3rd May, 2006if u have given AutoEventWireup="false" in the page directive then u have to give Handles StartProcessButtonClick.Click ie .. protected void StartProcessButtonClick(object sender, ImageClickEventArgs e)Handles StartProcessButtonClick.Click { if(sender is ImageButton) { // blah } } Other wise u have to make AutoEventWireup="true" I am not sure whether this little information will solve your problem
-
if u have given AutoEventWireup="false" in the page directive then u have to give Handles StartProcessButtonClick.Click ie .. protected void StartProcessButtonClick(object sender, ImageClickEventArgs e)Handles StartProcessButtonClick.Click { if(sender is ImageButton) { // blah } } Other wise u have to make AutoEventWireup="true" I am not sure whether this little information will solve your problem
I've tried changing the AutoEventWireup="true" but it doesn't make any difference, the event still fails to trigger. I wouldn't have thought a setting like that should affect it anyway (or, more to the point, if it was as simple as that, I wouldn't expect the code-behind call to trigger on any client at all, rather than working on some and not on others, as we're currently seeing). Any other ideas? ________________________ http://www.webreaper.net
-
I've tried changing the AutoEventWireup="true" but it doesn't make any difference, the event still fails to trigger. I wouldn't have thought a setting like that should affect it anyway (or, more to the point, if it was as simple as that, I wouldn't expect the code-behind call to trigger on any client at all, rather than working on some and not on others, as we're currently seeing). Any other ideas? ________________________ http://www.webreaper.net
Bit of extra info: the odd thing is that we have 2 production servers running exactly the same code - one is used as a 'staging' server (i.e., sand-box pre-production site used for external client testing) and the other is the actual production site. Both are configured identically (one used to be the real production system before we migrated it to an alternate hosting environment). The odd thing is that the IE client which exhibits the problem on the staging server, doesn't exhibit that behaviour on the production server. So you have the same binaries and presentation (.asXx) files on both servers, and yet the same IE client behaves differently depending on which server you use. And yet my machine works perfectly when I run against either server. It's a head-scratcher, alright... ________________________ http://www.webreaper.net -- modified at 6:58 Thursday 4th May, 2006