views:

177

answers:

6

I have created a server control out of the HtmlButton with validation disabled.

<button runat="server" causesvalidation="false" />

NOT the input button!!!

<input type="button" runat="server />

I have a bunch of validators on my form and when i click the HtmlButton they still run the validators. If I use the input button there is no problem and the validators don't run.

Is this expected behavior or is this a bug?

A: 

Still run the validators-- you mean client side, server side, or both?

Nicholas H
It only runs the on the server side. I have created new validators and it still runs them. They are not enabled/disabled in the code behind
Alex
+2  A: 

I tried it and it works as expected. I think you should check your code, maybe you're enabling it at server-side.

<button runat="server" ID="btnSubmit" causesvalidation="false"
 onserverclick="SubmitButton_Click"></button>

Just to overcome the problem, you can add validation group to your validations.

Canavar
What for in this case use `HtmlButton` instead of server-side `asp:Button` ?
abatishchev
A: 

You have no id on your button? That might be causing an issue where it doesn't know what the button is called therefore not loading all attributes for it. Long shot but you never know.

Robert
Sorry my bad. I do have an id in my code but i didn't include it in the example for brevity
Alex
A: 

After doing a little googling I came up with this: http://www.nedcomp.nl/support/origdocs/dotnetsdk/cpref/frlrfsystemwebuihtmlcontrolshtmlbuttonclasscausesvalidationtopic.htm

Hope it helps :)

John West
A: 

Depends on where the validations are used and if they are in the same group.you add validation restrictions on validation groups.if they are not in a group maybe the form's post to server causes it to validate the controls.

:)

A: 

All you have to do is set the attribute type="button". The default must be submit.

bboyd