Question

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.

Was it helpful?

Solution

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 !!!

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top