1

In Asp.net I am using this JQuery validation plugin.
It works perfect for <asp:Button> control. But if I use <asp:LinkButton> it does not validate the form and allows it to call code behind method.

Why is this happening? How can I able to validate form onClick event of <asp:LinkButton>?

EDIT: The problem with <asp:button> is we cannot able to add image on it. Check this.

0

2 Answers 2

2

The simple solution is to add a click function that returns false if the form is not valid:

$("#<%= tb.ClientID %>").click(function() {
       return $('form').valid();
})

more : ASP.NET LinkButton / ImageButton and JQuery Validate? Hope this will help !!!

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

2 Comments

thanks for reply, but #('form').valid(); is not working for the Validation plugin.
return jQuery('#formID').validationEngine('validate')); worked for the validation plugin I have been using.
0

You can use OnClientClick in order to call your client method

Link : http://msdn.microsoft.com/fr-fr/library/system.web.ui.webcontrols.linkbutton.onclientclick.aspx

Nota : OnClick is for ServerSide, OnClientClick is for Client Side

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.