码迷,mamicode.com
首页 > Web开发 > 详细

在一般处理程序(ashx)中弹出js提示语

时间:2016-12-25 01:25:01      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:前台   mit   write   type   static   自己   点击   string   javascrip   

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

  

在一般处理程序(ashx)中弹出js提示语

标签:前台   mit   write   type   static   自己   点击   string   javascrip   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!