<asp:button runat= "Server" id= "btn" text= "button"/>
The following is a reference fragment: public void Page_Load (Object Obj,eventargs E) { Btn. Attributes.Add ("onclick", "state=true;"); StringBuilder sb=new StringBuilder (); Sb. Append ("if (!state) return;"); Sb. Append ("var Button=document.getelementbyid (' btn ');"); Sb. Append ("button.value= ' please wait ... ';"); Sb. Append ("document.body.style.cursor= ' Wait ';"); Sb. Append ("button.disabled=true;"); String strscript= "<script>"; Strscript=strscript + "var state=false;"; To bind a function to a page's onbeforeunload event: Strscript=strscript + "window.attachevent (' onbeforeunload ', function () {" +SB. ToString () + "});"; Strscript=strscript + "</" + "script>"; Page.registerstartupscript ("onbeforeunload", strscript); } protected void Aa_click (object sender, EventArgs e) { Simulate a long time button processing System.Threading.Thread.Sleep (2000); Response.Write ("<script>alert (' bbbbbb!! ');" + "</" + "script>"); } |