日期:2014-05-16 浏览次数:20339 次
<%@ Page Language="C#" %> <%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Untitled Page</title> <script language="C#" runat="server"> public void Page_Load(object sender, EventArgs e) { btn1.Style["display"] = "none"; } public void Click1(object sender, EventArgs e) { Response.Write("提交了!"); } // 实现接口 public string m_CallbackResult; public string GetCallbackResult() { return m_CallbackResult; } public void RaiseCallbackEvent(string eventArgument) { // 这里做你的判断 if(eventArgument == "you") { m_CallbackResult = "0";// 已经有人正在申请同样的物资 } else { m_CallbackResult = "1";// 没有人正在申请同样的物资 } } </script> <script type="text/javascript" src="prototype.js"></script> <script type="text/javascript"> function CallServer(){ var arg = document.getElementById("txt1").value; <%=ClientScript.GetCallbackEventReference(this, "arg", "JsRecieve", null) %> } function JsRecieve(ret){ if(ret == "0"){ if(confirm("已经有人正在申请同样的物资,继续吗?")){ document.getElementById("btn1").click(); } }else document.getElementById("btn1").click(); } function SubmitCheck(){ CallServer(); return false; } </script> </head> <body> <form id="Form1" runat="server"> <asp:TextBox ID="txt1" runat="server"></asp:TextBox> <input type="button" onclick="SubmitCheck()" value="test" /> <asp:Button ID="btn1" runat="server" OnClick="Click1" Text="test" /> </form> </body> </html>