Question

This is my LinkButton:

<asp:LinkButton OnClientClick="Page_ClientValidate('validPanel1'); if(Page_IsValid==false) { console.log('error'); return false; }" ID="linkPanel1" ValidationGroup="validPanel1">Check</asp:LinkButton>

if the page is not valid, ok, I get the summary. If it's valid, it do a postback to the server (also if I have return false).

I don't want this. I want a sort of "void" function (later, I catch the event through a jquery handler).

How can I do it?

Was it helpful?

Solution

Link button is designed to postback every time, since it is server side control.

If you want to avoid its postback, you will have to handle all the code clientside, by writting javascript function.

Try Following:

LinkButton1.Attributes.Add("onclick", "JSFunction();return false;")

here JSFunction() is javascript function.

This will not postback.

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