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. button click event after onblur event

button click event after onblur event

Scheduled Pinned Locked Moved ASP.NET
csharpjavascriptasp-nethelptutorial
6 Posts 2 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.
  • G Offline
    G Offline
    gbabu17
    wrote on last edited by
    #1

    Hallo, I have a textbox with onblur event handled with javascript. I have asp.net button. When i chage the text in textbox and directly click the button, i get a confirm box from the onblur event. How can i make the button event to fire after answering the confirm box. In other cases like press tab or clicking some other control is not a problem. example code: Textbox txt = new TextBox txt.id = "txt"; txt.attributes.add("onblur","showmsg(this.id)") Javascript: function showmsg(id) { var x = document.getElementById(id).value; if (x != "") { var res = confirm("msg"); if (res == true) { document.getElementById(id).value = x; } else { document.getElementById(id).value = ""; } } }

    T 1 Reply Last reply
    0
    • G gbabu17

      Hallo, I have a textbox with onblur event handled with javascript. I have asp.net button. When i chage the text in textbox and directly click the button, i get a confirm box from the onblur event. How can i make the button event to fire after answering the confirm box. In other cases like press tab or clicking some other control is not a problem. example code: Textbox txt = new TextBox txt.id = "txt"; txt.attributes.add("onblur","showmsg(this.id)") Javascript: function showmsg(id) { var x = document.getElementById(id).value; if (x != "") { var res = confirm("msg"); if (res == true) { document.getElementById(id).value = x; } else { document.getElementById(id).value = ""; } } }

      T Offline
      T Offline
      ToddHileHoffer
      wrote on last edited by
      #2

      document.getelementbyid('yourButtonId').click();

      I didn't get any requirements for the signature

      G 1 Reply Last reply
      0
      • T ToddHileHoffer

        document.getelementbyid('yourButtonId').click();

        I didn't get any requirements for the signature

        G Offline
        G Offline
        gbabu17
        wrote on last edited by
        #3

        Thanks, But how to detect that it is button click event after onblur event. I mean i want to fire the button click event only if the button is pressed immediately after changing text in textbox.

        T 1 Reply Last reply
        0
        • G gbabu17

          Thanks, But how to detect that it is button click event after onblur event. I mean i want to fire the button click event only if the button is pressed immediately after changing text in textbox.

          T Offline
          T Offline
          ToddHileHoffer
          wrote on last edited by
          #4

          How come you can not do this the easy way and set the autopostaback of the textbox to true and use the code behind for that event? I don't have a good answer for you to know if an event occurs immediately after another event. You may have to use a global variable and a javascript timer. I have no idea.

          I didn't get any requirements for the signature

          G 1 Reply Last reply
          0
          • T ToddHileHoffer

            How come you can not do this the easy way and set the autopostaback of the textbox to true and use the code behind for that event? I don't have a good answer for you to know if an event occurs immediately after another event. You may have to use a global variable and a javascript timer. I have no idea.

            I didn't get any requirements for the signature

            G Offline
            G Offline
            gbabu17
            wrote on last edited by
            #5

            I do not want autopostback on textbox. There should be some way to detect button click event in javascript.

            T 1 Reply Last reply
            0
            • G gbabu17

              I do not want autopostback on textbox. There should be some way to detect button click event in javascript.

              T Offline
              T Offline
              ToddHileHoffer
              wrote on last edited by
              #6

              gbabu17 wrote:

              There should be some way to detect button click event in javascript.

              There is. Most HTML tags have onclick event. Reference this http://www.w3schools.com/jsref/jsref_onClick.asp[^]

              I didn't get any requirements for the signature

              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