Web弹框类_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > Web弹框类

Web弹框类

 2014/3/27 15:20:50  HappyOnTheRoad  博客园  我要评论(0)
  • 摘要:usingSystem;usingSystem.Text;namespaceCore{///<summary>///MessageBox的摘要说明。///</summary>publicclassMessageBox{publicMessageBox(){}///<summary>///弹出确认对话框///</summary>///<paramname="page">当前页</param>///<
  • 标签:Web
class="brush:csharp;gutter:true;">using System;
using System.Text;
namespace Core
{
    /// <summary>
    /// MessageBox 的摘要说明。
    /// </summary>
    public class MessageBox
    {
        public MessageBox()
        {
           
        }

        /// <summary>
        /// 弹出确认对话框
        /// </summary>
        /// <param name="page">当前页</param>
        /// <param name="msg">提示信息</param>
        public static void Show(System.Web.UI.Page page,string msg)
        {
            page.RegisterStartupScript("alert","<script language='javascript'>alert('"+msg+"');</script>");
        }
        //
        /// <summary>
        /// 控件点击 消息确认提示框
        /// </summary>
        /// <param name="page">当前页面指针,一般为this</param>
        /// <param name="msg">提示信息</param>
        public static void  Confirm(System.Web.UI.WebControls.WebControl Control,string msg)
        {
            Control.Attributes.Add("onclick", "return confirm('" + msg + "');") ;
        }

        /// <summary>
        /// 显示消息提示对话框,并进行页面跳转
        /// </summary>
        /// <param name="page">当前页面指针,一般为this</param>
        /// <param name="msg">提示信息</param>
        /// <param name="url">跳转的目标URL</param>
        public static void ShowAndRedirect(System.Web.UI.Page page, string msg, string url)
        {
            StringBuilder Builder = new StringBuilder();
            Builder.Append("<script language='javascript' defer>");
            Builder.AppendFormat("alert('{0}');", msg);
            Builder.AppendFormat("top.location.href='{0}'", url);
            Builder.Append("</script>");
            page.RegisterStartupScript("message", Builder.ToString());
        }
        /// <summary>
        /// 显示消息提示对话框,并进行页面跳转
        /// </summary>
        /// <param name="page">当前页面指针,一般为this</param>
        /// <param name="msg">提示信息</param>
        /// <param name="url">跳转的目标URL</param>
        /// <param name="name">如果是有板块的iframe 那么iframe 的name 就写这里</param>
        public static void ShowAndRedirect(System.Web.UI.Page page, string msg, string url, string name)
        {
            StringBuilder Builder = new StringBuilder();
            Builder.Append("<script language='javascript' defer>");
            Builder.AppendFormat("alert('{0}');", msg);
            Builder.AppendFormat("parent.{1}.location.href='{0}'", url, name);
            Builder.Append("</script>");
            page.RegisterStartupScript("message", Builder.ToString());
        }
    }
}

  转自http://blog.sina.com.cn/s/blog_617b12a40100i89q.html

发表评论
用户名: 匿名