문제

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