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('ctl00$contentmain$lbsave','')">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
Post a Comment