如果需要在客户端的button按钮点击的时候先去操作数据库然后在做一些其他事,这样每个客户端可以单独执行,并不影响效率
1)button的描述
<asp:Button ID=
"Button2" runat=
"server" Text=
"submit to ops" CssClass=
"button2"
OnClientClick= "javascript:return submitToOPS();" Height= "20px" Width= "113px"
OnClick= "Button2_Click" />
OnClientClick= "javascript:return submitToOPS();" Height= "20px" Width= "113px"
OnClick= "Button2_Click" />
2)script函数submitToOPS()
<
script
type
="text/javascript"
>
function submitToOPS()
{
if(!checkSelect())
{
alert("Please select one item!");
return false;
}
$('callInfo').style.display="";
CallBackToOPS();
return false;
}
function CallBackToOPS()
{
Anthem_InvokePageMethod(
'SendToOPS',
[],
function(result) {
if(result.value.length!=0)
{
$('callInfo').style.display="none";
open('../batch.aspx?type=0','','height=450,width=800,top=200,left=120,toolbar=no,menubar=no,scrollbars=no, resizable=yes,location=no, status=no');
}
}
);
}
</script>
function submitToOPS()
{
if(!checkSelect())
{
alert("Please select one item!");
return false;
}
$('callInfo').style.display="";
CallBackToOPS();
return false;
}
function CallBackToOPS()
{
Anthem_InvokePageMethod(
'SendToOPS',
[],
function(result) {
if(result.value.length!=0)
{
$('callInfo').style.display="none";
open('../batch.aspx?type=0','','height=450,width=800,top=200,left=120,toolbar=no,menubar=no,scrollbars=no, resizable=yes,location=no, status=no');
}
}
);
}
</script>
3)服务器函数SendToOPS()
[Anthem.Method]
public string SendToOPS()
{
string result = string.Empty;
if (GridView1.Rows.Count != 0)
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
GridViewRow row = GridView1.Rows[i];
System.Web.UI.WebControls.CheckBox checkBox = (System.Web.UI.WebControls.CheckBox)row.FindControl("CheckBox1");
string id = GridView1.DataKeys[i]["Booking_No"].ToString();
string carrier = GridView1.DataKeys[i]["Carrier"].ToString();
string branch = this.GridView1.DataKeys[i]["Mlog_Entity"].ToString();
if (checkBox.Checked)
{
SubmitBatch(id, carrier, branch);
}
}
result = "ok";
}
return result;
}
public string SendToOPS()
{
string result = string.Empty;
if (GridView1.Rows.Count != 0)
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
GridViewRow row = GridView1.Rows[i];
System.Web.UI.WebControls.CheckBox checkBox = (System.Web.UI.WebControls.CheckBox)row.FindControl("CheckBox1");
string id = GridView1.DataKeys[i]["Booking_No"].ToString();
string carrier = GridView1.DataKeys[i]["Carrier"].ToString();
string branch = this.GridView1.DataKeys[i]["Mlog_Entity"].ToString();
if (checkBox.Checked)
{
SubmitBatch(id, carrier, branch);
}
}
result = "ok";
}
return result;
}