javascript - stopping a server side function in c# -
my code :
<asp:linkbutton id="search" cssclass="button" runat="server" text='<%$resources:strings,search %>' onclick="search_click" />
server side :
protected void search_click(object sender, eventargs e) { var script = "checkifitemselected()"; scriptmanager.registerstartupscript(this, gettype(), "myscript", script, true); }
client side :
function checkifitemselected() { var salesmanselecteditem = $find('<%= salesmangrid_grd.clientid %>').get_mastertableview().get_selecteditems().length; var productsselecteditem = $find('<%= salsemanproductsgrid_grd.clientid %>').get_mastertableview().get_selecteditems().length; if (salesmanselecteditem == 0 && productsselecteditem == 0) { $("#<%=errormsg.clientid %>").html("please select salesman @ least<br>please select product @ least"); return false; } if (salesmanselecteditem == 0) { $("#<%=errormsg.clientid %>").html("please select salesman @ least"); return false ; } if (productsselecteditem == 0) { $("#<%=errormsg.clientid %>").html("please select product @ least"); return false; } $("#<%=errormsg.clientid %>").html(""); return true; }
the question if client side function return false want stop server side function continue how should ?
found solution hope wld :
protected void search_click(object sender, eventargs e) { int selectedsalesmans= salesmangrid_grd.selecteditems.count; int selectedproducts = salsemanproductsgrid_grd.selecteditems.count; if (selectedsalesmans == 0) { var script = "displayerrormsg(\"please choose salesman @ least. \")"; scriptmanager.registerstartupscript(this, gettype(), "myscript", script, true); return; } if (selectedproducts == 0) { var script = "displayerrormsg(\"please choose product @ least. \")"; scriptmanager.registerstartupscript(this, gettype(), "myscript", script, true); return; } }
client side:
function displayerrormsg(msg) { $("#<%=errormsg.clientid %>").html(msg); }
Comments
Post a Comment