弹出窗口

之前的弹出窗口是这样写的:
 this.Response.Write("<script language=javascript>alert('xxxx!');window.window.location.href='url';</script>");

现在写成一个类,方便一点

 public sealed class MessageBox
    {
       
        
         public static void  show( System .Web .UI .Page page,string msg,string url)
         {
             page.Response.Write("<script language=javascript>");
             page.Response.Write("alert('");
             page.Response.Write(msg);
             page.Response.Write("');");
             if (url != null)
             {
                 page.Response.Write("window.window.location.href='");
                 page.Response.Write(url);
                 page.Response.Write("';</script>");
             }
             else { page.Response.Write("');</script>"); }


             
             //page.Response.Write("');</script>");
         }

         public static void show(System.Web.UI.UserControl page, string msg, string url)
         {
             page.Response.Write("<script language=javascript>");
             page.Response.Write("alert('");
             page.Response.Write(msg);
             page.Response.Write("');");
             if (url != null)
             {
                 page.Response.Write("window.window.location.href='");
                 page.Response.Write(url);
                 page.Response.Write("';</script>");
             }
             else { page.Response.Write("');</script>"); }
        
         }
        
        
         public MessageBox()
         { }

你可能感兴趣的:(弹出窗口)