2
我的代碼:停止服務器端函數在C#
<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我想停止服務器端功能,我應該怎麼做?