在提交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("你的提示語!");PS:Js中$.ajax調用一般處理程序(.ashx)
$.ajax({          type: "post",          url: "/tools/ActApply.ashx",          data: "txthdmoney=" + $.trim($("#hdmoneyx")[0].value)+"&sxf=2",          success: function (result) {                      }        });.ashx后臺接收數據
  protected decimal hdmoney;    protected decimal hdsxf;    /// <summary>    /// 請求處理    /// </summary>    /// <param name="context"></param>    public void ProcessRequest(HttpContext context)    {      Withdrawal withdra = new Withdrawal();      context.Response.ContentType = "text/plain";      hdmoney = Convert.ToDecimal(context.Request.Params["txthdmoney"].ToString());      hdsxf = Convert.ToDecimal(context.Request.Params["sxf"].ToString());      SaveAct();    }    public bool IsReusable    {      get      {        return false;      }    }總結
以上所述是小編給大家介紹的在一般處理程序(ashx)中彈出js提示語,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!
新聞熱點
疑難解答