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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top