在提交form表單時,比如前台是$("form").submit()同步提交的時候,這個是沒有回掉函數的,那么我們只能在后台提示,在前台顯示,自己作為一個參考吧
public class Script { public static void Alert(string message) { ResponseScript("alert('" + message + "');window.location = '彈出提示語后,點擊確認跳到你想跳的頁面';"); } public static void ResponseScript(string script) { HttpContext.Current.Response.Write("<script type=\"text/javascript\">\n//<![CDATA[\n"); HttpContext.Current.Response.Write(script); HttpContext.Current.Response.Write("\n//]]>\n</script>\n"); } }
還有就是將一般處理程序默認的 //context.Response.ContentType = "text/plain";改為 context.Response.ContentType = "text/html";
我們調用的時候直接: Script.Alert("你的提示語!");