0

i have a form it has to be validated before code behind of button fires

< asp: button id="btn1" runat="server" usesubmittbehaviour="false" onclientclick="validate(this) return"/>

and there is click event in code behind, but when the validate returns true click event of button not firing..

1 Answer 1

2

You should change

validate(this) return

with

return validate(this)

in the onclientclick attribute

Sign up to request clarification or add additional context in comments.

3 Comments

OnClientClick="if (!validate(this)) return;" i did this way..but not working
@Gani, what you have typed above is actually the correct answer. The actual rendered script will be something like this onclick="if(!validate(this)) return;__doPostBack(&#39;ctl00$MainContent$btn1&#39;,&#39;&#39;)" which is what you want.
@MARC with useSubmitBehavior="false" when any validation is false then a alert popup's and when i click OK on popup the page is automatically refreshing ,i dont want this to happen .How can i do this ??

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.