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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Unable to disable the button

Unable to disable the button

Scheduled Pinned Locked Moved ASP.NET
helpcom
7 Posts 2 Posters 1 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.
  • V Offline
    V Offline
    vnr
    wrote on last edited by
    #1

    Hi, In my application i have a form where in which when i submit the form by clicking on the submit button it will do some operation .This operation has to be performed only once so i have disabled that button once it gets clicked to avoid the multiple clicks of it by writing the code Button1.Enabled = false; in the button click event , this is working fine but when i am redirecting to another page after completion of the operation in that button click code , the button is not getting disabled .Because of this, even though i have disabled the button when a user clicks on the button multiple times that particular operation is getting executed the number of times the button is clicked instead only once . here is my button click code protected void Button1_Click(object sender, EventArgs e) { Button1.Enabled = false; Response.Redirect("http://abc.com/test.apsx"); } Please can anyone help me to resolve this problem Thanks in advance

    B 1 Reply Last reply
    0
    • V vnr

      Hi, In my application i have a form where in which when i submit the form by clicking on the submit button it will do some operation .This operation has to be performed only once so i have disabled that button once it gets clicked to avoid the multiple clicks of it by writing the code Button1.Enabled = false; in the button click event , this is working fine but when i am redirecting to another page after completion of the operation in that button click code , the button is not getting disabled .Because of this, even though i have disabled the button when a user clicks on the button multiple times that particular operation is getting executed the number of times the button is clicked instead only once . here is my button click code protected void Button1_Click(object sender, EventArgs e) { Button1.Enabled = false; Response.Redirect("http://abc.com/test.apsx"); } Please can anyone help me to resolve this problem Thanks in advance

      B Offline
      B Offline
      Brij
      wrote on last edited by
      #2

      are you redirecting user to same page?

      Cheers!! Brij

      V 1 Reply Last reply
      0
      • B Brij

        are you redirecting user to same page?

        Cheers!! Brij

        V Offline
        V Offline
        vnr
        wrote on last edited by
        #3

        Hi, thanks for the reply , no i am not redirecting to the same page .I need to to redirect it other page. Thanks

        B 1 Reply Last reply
        0
        • V vnr

          Hi, thanks for the reply , no i am not redirecting to the same page .I need to to redirect it other page. Thanks

          B Offline
          B Offline
          Brij
          wrote on last edited by
          #4

          Your Qs is not clear.When you redirect to another page then how the button which was on earlier page is visible. Anyways you can have a flag in session set it when user click on the button once and put your enable/disable button code on the pageload.

          Cheers!! Brij

          V 1 Reply Last reply
          0
          • B Brij

            Your Qs is not clear.When you redirect to another page then how the button which was on earlier page is visible. Anyways you can have a flag in session set it when user click on the button once and put your enable/disable button code on the pageload.

            Cheers!! Brij

            V Offline
            V Offline
            vnr
            wrote on last edited by
            #5

            Hi, When the current page is redirecting to another page it is taking some time , in that time only user can click on the button multiple times .As you said if I use session there may be a chance of user clearing the browser sessions , if it does not happen also for the first button click i will do some operation and the result of that operation has to be sent to another page but if I use the session for the first click of the button some operation is done and trying to redirect to another page and meanwhile if user again clicks on the button i will check for the session and will not perform the same operation again but redirection will not happen in this case . Please suggest me the solution. Thanks

            B 1 Reply Last reply
            0
            • V vnr

              Hi, When the current page is redirecting to another page it is taking some time , in that time only user can click on the button multiple times .As you said if I use session there may be a chance of user clearing the browser sessions , if it does not happen also for the first button click i will do some operation and the result of that operation has to be sent to another page but if I use the session for the first click of the button some operation is done and trying to redirect to another page and meanwhile if user again clicks on the button i will check for the session and will not perform the same operation again but redirection will not happen in this case . Please suggest me the solution. Thanks

              B Offline
              B Offline
              Brij
              wrote on last edited by
              #6

              Ok try to disable it from javascript.It should work

              Cheers!! Brij

              V 1 Reply Last reply
              0
              • B Brij

                Ok try to disable it from javascript.It should work

                Cheers!! Brij

                V Offline
                V Offline
                vnr
                wrote on last edited by
                #7

                Hi Brij, Thanks for your support, I have tried it using java script and its worked for me. I have taken a hidden field , for the first click of the button i will assign some value to that hidden field .For every hit of the button one java script function will be called and there i will check for the hidden field value , if there is any value in it i will not do anything.

                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