Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. ImageButton Server-side OnClick handler doesn't always get called

ImageButton Server-side OnClick handler doesn't always get called

Scheduled Pinned Locked Moved ASP.NET
csharpsysadminregexquestion
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mark Otway
    wrote on last edited by
    #1

    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

    J L 2 Replies Last reply
    0
    • M Mark Otway

      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

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #2

      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

      M 1 Reply Last reply
      0
      • J J4amieC

        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

        M Offline
        M Offline
        Mark Otway
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • M Mark Otway

          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

          L Offline
          L Offline
          lijukv
          wrote on last edited by
          #4

          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

          M 1 Reply Last reply
          0
          • L lijukv

            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

            M Offline
            M Offline
            Mark Otway
            wrote on last edited by
            #5

            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

            M 1 Reply Last reply
            0
            • M Mark Otway

              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

              M Offline
              M Offline
              Mark Otway
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups