Prevent Validation From Normal HTML Controls
-
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 theEnableClientScript
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 theCausesValidation
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 isAdd Line</button>
but I haven't figured out a way to add thedata-bind='click: addLine'
to an ASP.NET button (I have triedOnClickClient='addLine'
but this didn't work either. Any suggestions or information that can help resolve this issue would be greatly appreciated. Thank YouA 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.
-
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 theEnableClientScript
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 theCausesValidation
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 isAdd Line</button>
but I haven't figured out a way to add thedata-bind='click: addLine'
to an ASP.NET button (I have triedOnClickClient='addLine'
but this didn't work either. Any suggestions or information that can help resolve this issue would be greatly appreciated. Thank YouA 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.
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 youraddLine
method returnstrue
, 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
-
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 theEnableClientScript
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 theCausesValidation
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 isAdd Line</button>
but I haven't figured out a way to add thedata-bind='click: addLine'
to an ASP.NET button (I have triedOnClickClient='addLine'
but this didn't work either. Any suggestions or information that can help resolve this issue would be greatly appreciated. Thank YouA 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.
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.