在一般处理程序(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">
//<![CDATA[
");
                HttpContext.Current.Response.Write(script);
                HttpContext.Current.Response.Write("
//]]>
</script>
");
            }
        }

  

还有就是将一般处理程序默认的 //context.Response.ContentType = "text/plain";改为
            context.Response.ContentType = "text/html";

  

我们调用的时候直接:

Script.Alert("你的提示语!");

  

原文地址:https://www.cnblogs.com/hbh123/p/6218671.html