在一般處理程序(ashx)中彈出js提示語


在提交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("你的提示語!");

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM