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. How to disable a button and still have the click event to fire.

How to disable a button and still have the click event to fire.

Scheduled Pinned Locked Moved ASP.NET
helptutorial
4 Posts 4 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
    Martin_
    wrote on last edited by
    #1

    Hello again, I need help trying to get this to work. I want to disable a button when clicked, so that the user doesn’t clicking it again. function Form1_onSubmit() { Form1.btnSaveBudget.disabled=true; } ... However, when the button gets disabled then the click event won’t work. Protected Sub btn_Click(...) Handles btn.Click I need the click event to fire to do something. Thank you </x-turndown>

    L V K 3 Replies Last reply
    0
    • M Martin_

      Hello again, I need help trying to get this to work. I want to disable a button when clicked, so that the user doesn’t clicking it again. function Form1_onSubmit() { Form1.btnSaveBudget.disabled=true; } ... However, when the button gets disabled then the click event won’t work. Protected Sub btn_Click(...) Handles btn.Click I need the click event to fire to do something. Thank you </x-turndown>

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Hey I am not a JS expert but here are some suggestions: Is the on_submit function not meant to return a value? Does returning true make it work. Does it post back at all? If this doesnt sort it how about instead of disabling it just ignoring it so you would set a bool to true on first press then on further presses check this value and ignore the event. Hope this helps Dan

      1 Reply Last reply
      0
      • M Martin_

        Hello again, I need help trying to get this to work. I want to disable a button when clicked, so that the user doesn’t clicking it again. function Form1_onSubmit() { Form1.btnSaveBudget.disabled=true; } ... However, when the button gets disabled then the click event won’t work. Protected Sub btn_Click(...) Handles btn.Click I need the click event to fire to do something. Thank you </x-turndown>

        V Offline
        V Offline
        Venkatesh Mookkan
        wrote on last edited by
        #3

        You are capturing Form OnSubmit event, which happens before the page postback. Form submit must return true. Add a line return true, so that it will postback.

        Martin_ wrote:

        Form1.btnSaveBudget.disabled=true;

        Another suggestion, this type of object identification will not work on all browsers. Start using document.getElementById('<OBJECT_NAME>').

        Regards, Venkatesh Mookkan. Software Engineer, India My: Website | Yahoo Group | Blog Spot

        1 Reply Last reply
        0
        • M Martin_

          Hello again, I need help trying to get this to work. I want to disable a button when clicked, so that the user doesn’t clicking it again. function Form1_onSubmit() { Form1.btnSaveBudget.disabled=true; } ... However, when the button gets disabled then the click event won’t work. Protected Sub btn_Click(...) Handles btn.Click I need the click event to fire to do something. Thank you </x-turndown>

          K Offline
          K Offline
          K P Kannan
          wrote on last edited by
          #4

          Have a javascript registered through page.registerstartupscript and enable the button through that

          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