c# - How to prevent postback from asp.net linkbutton -


asp:

<asp:linkbutton id="lbsave" onclick="lbsave_click" runat="server">save</asp:linkbutton> 

html:

<a id="contentmain_lbsave" href="javascript:__dopostback(&#39;ctl00$contentmain$lbsave&#39;,&#39;&#39;)">save</a> 

code-behind:

public void lbsave_click(object sender, eventargs e)     {         if (strp != "")         {             scriptmanager.registerstartupscript(this.page, typeof(page), "diffuser", "showdiffuser();", true);         }         else         {             //do else...         }     } 

jquery:

function showdiffuser() {     $("#dvhide").fadein("slow");     $("#backoverlay").fadein("slow"); } 

when click button, want page not postback , run jquery function. instead, when click link refreshes page , executes jquery function.

how can prevent postback.

i tried following: onclientclick='javascript:void(0);' doesn't execute jquery function.

try

onclientclick="return false;" 

update:

onclientclick="showdiffuser();return false;" 

showdiffuser(); calls js-method

return false; prevents postback


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -