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. Prevent Validation From Normal HTML Controls

Prevent Validation From Normal HTML Controls

Scheduled Pinned Locked Moved ASP.NET
helpcsharpjavascripthtmlasp-net
3 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.
  • D Offline
    D Offline
    Dominick Marciano
    wrote on last edited by
    #1

    I'm currently designing a page using ASP.NET and JQuery which is very similar to an order form. The page has two ASP.NET Panels; the first one contains ASP.NET controls for some general information. These controls all have validators associated with them, all part of the validation group "vgRequest", along with a validation summary control which is also part of the vgRequest group. The second Panel contains only HTML text boxes () and two buttons (). When one of the buttons is clicked, it is supposed to call a JQuery function, however the HTML button is causes the ASP.NET validators to run. I do not want this to happen as at the very end of the page there is another ASP.NET button which should cause the validation to run. I have tried setting the EnableClientScript property on the validation summary control to False but this didn't help. I've also tried searching on Google but everything I've come across talks about using controls. Is there anyway to prevent normal HTML controls from causes the ASP.NET validators to run? I know I could use and set the CausesValidation property to False, but I don't know if this is an option. I'm using the Knockout library and the button I currently have is Add Line</button> but I haven't figured out a way to add the data-bind='click: addLine' to an ASP.NET button (I have tried OnClickClient='addLine' but this didn't work either. Any suggestions or information that can help resolve this issue would be greatly appreciated. Thank You

    A black hole is where God tried to divide by zero. There are 10 kinds of people in the world; those who understand binary and those who don't.

    Richard DeemingR J 2 Replies Last reply
    0
    • D Dominick Marciano

      I'm currently designing a page using ASP.NET and JQuery which is very similar to an order form. The page has two ASP.NET Panels; the first one contains ASP.NET controls for some general information. These controls all have validators associated with them, all part of the validation group "vgRequest", along with a validation summary control which is also part of the vgRequest group. The second Panel contains only HTML text boxes () and two buttons (). When one of the buttons is clicked, it is supposed to call a JQuery function, however the HTML button is causes the ASP.NET validators to run. I do not want this to happen as at the very end of the page there is another ASP.NET button which should cause the validation to run. I have tried setting the EnableClientScript property on the validation summary control to False but this didn't help. I've also tried searching on Google but everything I've come across talks about using controls. Is there anyway to prevent normal HTML controls from causes the ASP.NET validators to run? I know I could use and set the CausesValidation property to False, but I don't know if this is an option. I'm using the Knockout library and the button I currently have is Add Line</button> but I haven't figured out a way to add the data-bind='click: addLine' to an ASP.NET button (I have tried OnClickClient='addLine' but this didn't work either. Any suggestions or information that can help resolve this issue would be greatly appreciated. Thank You

      A black hole is where God tried to divide by zero. There are 10 kinds of people in the world; those who understand binary and those who don't.

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      It sounds like your addLine function isn't preventing the default click action. As a result, the button will submit the form, which will cause the validators to run on the server. According to the Knockout documentation[^], if your addLine method returns true, the default click action will run. Adding the binding attribute to an ASP.NET button should be as simple as:

      <asp:Button runat="server"
      CausesValidation="false"
      Text="Add Line"
      data-bind="click: addLine"
      />

      Any attributes which don't map to properties on the control will be passed through unchanged.


      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      • D Dominick Marciano

        I'm currently designing a page using ASP.NET and JQuery which is very similar to an order form. The page has two ASP.NET Panels; the first one contains ASP.NET controls for some general information. These controls all have validators associated with them, all part of the validation group "vgRequest", along with a validation summary control which is also part of the vgRequest group. The second Panel contains only HTML text boxes () and two buttons (). When one of the buttons is clicked, it is supposed to call a JQuery function, however the HTML button is causes the ASP.NET validators to run. I do not want this to happen as at the very end of the page there is another ASP.NET button which should cause the validation to run. I have tried setting the EnableClientScript property on the validation summary control to False but this didn't help. I've also tried searching on Google but everything I've come across talks about using controls. Is there anyway to prevent normal HTML controls from causes the ASP.NET validators to run? I know I could use and set the CausesValidation property to False, but I don't know if this is an option. I'm using the Knockout library and the button I currently have is Add Line</button> but I haven't figured out a way to add the data-bind='click: addLine' to an ASP.NET button (I have tried OnClickClient='addLine' but this didn't work either. Any suggestions or information that can help resolve this issue would be greatly appreciated. Thank You

        A black hole is where God tried to divide by zero. There are 10 kinds of people in the world; those who understand binary and those who don't.

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

        Just a stab in the dark here. onClientClick="jquery_validate(); return false;" The return false cancels the button click event, which in turn cancels the validation. [edit] Or you use a non-button like an image or span element, and bind the click in the jquery validator or the document.ready, so it doesn't act like a HTML button, but fires the event. I think you can fabricate a button using span and some css.

        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