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. onsubmit event

onsubmit event

Scheduled Pinned Locked Moved ASP.NET
jsonhelptutorialquestion
4 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.
  • A Offline
    A Offline
    Ali Al Omairi Abu AlHassan
    wrote on last edited by
    #1

    guys; I use onsubmit event to add some data to the request when the form is submitting, but i notice that the handler is called when a submit button is clicked but not when .submit() function is called for the form. i don't know if this is normal. if so, what else can i try? another disappointing thing is that i found this sentence in this page[^] The form's onsubmit event handler (for example, onsubmit="return false;") will not be triggered when invoking this method.

    Help people,so poeple can help you.

    J 1 Reply Last reply
    0
    • A Ali Al Omairi Abu AlHassan

      guys; I use onsubmit event to add some data to the request when the form is submitting, but i notice that the handler is called when a submit button is clicked but not when .submit() function is called for the form. i don't know if this is normal. if so, what else can i try? another disappointing thing is that i found this sentence in this page[^] The form's onsubmit event handler (for example, onsubmit="return false;") will not be triggered when invoking this method.

      Help people,so poeple can help you.

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

      I'll take a stab at this, perhaps I will make some sense here. I think you are confusing a regular HTML page with an asp.net page. It took me a couple of years to figure out asp.net, and how it handles the submit button. One of the caveats of asp.net, is that you can only have 1 form tag. So you can't wrap multiple submit buttons with their own form tag, to create multiple default buttons. Instead asp.net uses a script manager I want to say, I think that is what controls the submit behavior, which in turn writes JavaScript to control form action. So to create multiple submit buttons, you have to wrap each form area in a container like a panel, and set the default button of that panel to the submit button inside the panel container. So to answer your question: On a button control like image button or button You control the button with OnClientClick = "run_javascript(); return false;" Add Handler click Address Of button_click So you can run JavaScript to validate, run a webservice, and based on what you return, say false, the handler will not fire the button event, or true, the handler will fire the button event. Now there are ways to control the page submit event, but you have to be more precise as to what you want to do. In the run_javascript above, you can use JavaScript to reprogram data in text boxes or input elements, that will post back to the server, thus the name input element.

      A 1 Reply Last reply
      0
      • J jkirkerx

        I'll take a stab at this, perhaps I will make some sense here. I think you are confusing a regular HTML page with an asp.net page. It took me a couple of years to figure out asp.net, and how it handles the submit button. One of the caveats of asp.net, is that you can only have 1 form tag. So you can't wrap multiple submit buttons with their own form tag, to create multiple default buttons. Instead asp.net uses a script manager I want to say, I think that is what controls the submit behavior, which in turn writes JavaScript to control form action. So to create multiple submit buttons, you have to wrap each form area in a container like a panel, and set the default button of that panel to the submit button inside the panel container. So to answer your question: On a button control like image button or button You control the button with OnClientClick = "run_javascript(); return false;" Add Handler click Address Of button_click So you can run JavaScript to validate, run a webservice, and based on what you return, say false, the handler will not fire the button event, or true, the handler will fire the button event. Now there are ways to control the page submit event, but you have to be more precise as to what you want to do. In the run_javascript above, you can use JavaScript to reprogram data in text boxes or input elements, that will post back to the server, thus the name input element.

        A Offline
        A Offline
        Ali Al Omairi Abu AlHassan
        wrote on last edited by
        #3

        Thank you Sir My problem was't in validation but in add some data to the request that identify is used to distinguish between request threads associated with the page but not the session. my problem was that some post request is made by calling the pre-defined function __doPostBack that calls .submit for the form so the event would not be triggered. instead i added a custom validator with a validation function that adds my desired data and not to modify .IsValid value. in this way the framework would call DoBostPackWithOptions instead of __doPostBack so the my custom validation function would be called and when a submit button is clicked the function Page_ClientValidate would be called by triggering on submit event.

        Help people,so poeple can help you.

        J 1 Reply Last reply
        0
        • A Ali Al Omairi Abu AlHassan

          Thank you Sir My problem was't in validation but in add some data to the request that identify is used to distinguish between request threads associated with the page but not the session. my problem was that some post request is made by calling the pre-defined function __doPostBack that calls .submit for the form so the event would not be triggered. instead i added a custom validator with a validation function that adds my desired data and not to modify .IsValid value. in this way the framework would call DoBostPackWithOptions instead of __doPostBack so the my custom validation function would be called and when a submit button is clicked the function Page_ClientValidate would be called by triggering on submit event.

          Help people,so poeple can help you.

          J Offline
          J Offline
          jkirkerx
          wrote on last edited by
          #4

          Oh OK, that makes sense to me. I just call a jquery function using onClientClick and return the value of the function. I gave up on the Microsoft validation stuff years ago. I haven't seen a post here for _doPostBack in years, but it was a popular subject at ASPNet.com several years back.

          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