asp.net web 后台判断提示框,点击'是'执行代码A(),点击'否'执行代码B()

html code
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="btnCallBack" runat="server" Text="回发并弹出confirm" OnClick="btnCallBack_Click" />
<asp:Button ID="btnHid" runat="server" OnClick="btnHid_Click" Width="0px" />
<asp:HiddenField ID="hid" runat="server" />
</div>
</form>
</body>
</html>

后台:

protected void btnCallBack_Click(object sender, EventArgs e)
{
//do sth
string js = string.Format("document.getElementById('{0}').value=confirm('是否确认?');document.getElementById('{1}').click();", hid.ClientID,btnHid.ClientID);
ClientScript.RegisterStartupScript(GetType(), "confirm", js, true);
}
protected void btnHid_Click(object sender, EventArgs e)
{
string result = hid.Value.ToLower() == "true" ? "是" : "否";
Response.Write(string.Format("您选择的是{0}",result));
}
上一篇:fidder监控请求响应时间和请求IP(摘抄至网络)


下一篇:angularjs揭秘