我的代码:
<asp:LinkButton ID="Search" CssClass="button" runat="server" Text='<%$Resources:Strings,Search %>' OnClick="Search_Click" />
服务器端 :
protected void Search_Click(object sender, EventArgs e)
{
var script = "CheckIfItemSelected()";
ScriptManager.RegisterStartupScript(this, GetType(), "MyScript", script, true);
}
客户端 :
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 a salesman at least<br>please select a product at least");
return false;
}
if (SalesmanSelectedItem == 0) {
$("#<%=ErrorMsg.ClientID %>").html("please select a salesman at least");
return false ;
}
if (ProductsSelectedItem == 0) {
$("#<%=ErrorMsg.ClientID %>").html("please select a product at least");
return false;
}
$("#<%=ErrorMsg.ClientID %>").html("");
return true;
}
问题是如果我的客户端函数返回 false 我想停止服务器端函数继续我应该怎么做?