写了个各种消息框的类
写了个各种消息框的类,以后要用可直接调用了
public class Message
{
警告消息框#region 警告消息框
/**//// <summary>
/// 警告消息框
/// </summary>
/// <param name="str_Message">提示信息,例子:"不能为空!"</param>
public static void Alert(string str_Message)
{
Page ParameterPage = (Page)System.Web.HttpContext.Current.Handler;
ParameterPage.RegisterStartupScript("alert","<script language='JavaScript'>alert('"+str_Message+"');</script>");
}
/**//// <summary>
/// 服务器端弹出alert对话框,并使控件获得焦点
/// </summary>
/// <param name="str_Ctl_Name">获得焦点控件Id值,比如:txt_Name</param>
/// <param name="str_Message">提示信息,例子:"请输入您姓名!"</param>
public static void Alert(string str_Ctl_Name,string str_Message)
{
Page ParameterPage = (Page)System.Web.HttpContext.Current.Handler;
ParameterPage.RegisterStartupScript("alert","<script language='JavaScript'>alert('"+str_Message+"');document.forms(0)."+str_Ctl_Name+".focus(); document.forms(0)."+str_Ctl_Name+".select();</script>");
}
#endregion
确认消息框#region 确认消息框
/**//// <summary>
/// 弹出confirm对话框-实现页面跳转
/// </summary>
/// <param name="PageTarget">跳转到的页面</param>
/// <param name="Content">提示信息</param>
public static void Confirm(string PageTarget,string str_Message)
{
Page ParameterPage = (Page)System.Web.HttpContext.Current.Handler;
ParameterPage.RegisterStartupScript("confirm","<script language='JavaScript'>var retValue=window.confirm('"+str_Message+"');"+"if(retValue){window.location='"+PageTarget+"';}</script>");
}
/**//// <summary>
/// 弹出confirm对话框-提示信息
/// </summary>
/// <param name="str_Message">提示信息</param>
public static void Confirm(string str_Message)
{
Page ParameterPage = (Page)System.Web.HttpContext.Current.Handler;
ParameterPage.RegisterStartupScript("confirm","<script language='JavaScript'>var retValue=window.confirm('"+str_Message+"');</script>");
}
/**//// <summary>
/// 服务器端弹出confirm对话框,询问用户准备转向那些操作,包括“确定”和“取消”时的操作
/// </summary>
/// <param name="str_Message">提示信息,比如:"成功增加数据,单击\"确定\"按钮填写流程,单击\"取消\"修改数据"</param>
/// <param name="btn_Redirect_Flow">"确定"按钮id值</param>
/// <param name="btn_Redirect_Self">"取消"按钮id值</param>
/// <param name="page">Page类</param>
public static void Confirm(string str_Message,string btn_Redirect_Flow,string btn_Redirect_Self)
{
Page ParameterPage = (Page)System.Web.HttpContext.Current.Handler;
ParameterPage.RegisterStartupScript("","<script> if (confirm('"+str_Message+"')==true){document.forms(0)."+btn_Redirect_Flow+".click();}else{document.forms(0)."+btn_Redirect_Self+".click();}</script>");
}
/**//// <summary>
/// 弹出confirm对话框-激活Botton的事件
/// </summary>
/// <param name="str_Message">提示信息,例子:"您是否确认删除!"</param>
/// <param name="btn">隐藏Botton按钮Id值,比如:btn_Flow</param>
public static void ConfirmMessage(string str_Message,string btn)
{
Page ParameterPage = (Page)System.Web.HttpContext.Current.Handler;
ParameterPage.RegisterStartupScript("confirm","<script> if(confirm('"+str_Message+"')==true){document.forms(0)."+btn+".click();}</script>");
}
#endregion
提示消息框#region 提示消息框
/**//// <summary>
/// 提示消息框
/// </summary>
/// <param name="str_Message">提示信息</param>
public static void prompt(string str_Message)
{
Page ParameterPage = (Page)System.Web.HttpContext.Current.Handler;
ParameterPage.RegisterStartupScript("prompt","<script language='JavaScript'>window.prompt('"+str_Message+"');</script>");
}
#endregion
}
{
警告消息框#region 警告消息框
/**//// <summary>
/// 警告消息框
/// </summary>
/// <param name="str_Message">提示信息,例子:"不能为空!"</param>
public static void Alert(string str_Message)
{
Page ParameterPage = (Page)System.Web.HttpContext.Current.Handler;
ParameterPage.RegisterStartupScript("alert","<script language='JavaScript'>alert('"+str_Message+"');</script>");
}
/**//// <summary>
/// 服务器端弹出alert对话框,并使控件获得焦点
/// </summary>
/// <param name="str_Ctl_Name">获得焦点控件Id值,比如:txt_Name</param>
/// <param name="str_Message">提示信息,例子:"请输入您姓名!"</param>
public static void Alert(string str_Ctl_Name,string str_Message)
{
Page ParameterPage = (Page)System.Web.HttpContext.Current.Handler;
ParameterPage.RegisterStartupScript("alert","<script language='JavaScript'>alert('"+str_Message+"');document.forms(0)."+str_Ctl_Name+".focus(); document.forms(0)."+str_Ctl_Name+".select();</script>");
}
#endregion
确认消息框#region 确认消息框
/**//// <summary>
/// 弹出confirm对话框-实现页面跳转
/// </summary>
/// <param name="PageTarget">跳转到的页面</param>
/// <param name="Content">提示信息</param>
public static void Confirm(string PageTarget,string str_Message)
{
Page ParameterPage = (Page)System.Web.HttpContext.Current.Handler;
ParameterPage.RegisterStartupScript("confirm","<script language='JavaScript'>var retValue=window.confirm('"+str_Message+"');"+"if(retValue){window.location='"+PageTarget+"';}</script>");
}
/**//// <summary>
/// 弹出confirm对话框-提示信息
/// </summary>
/// <param name="str_Message">提示信息</param>
public static void Confirm(string str_Message)
{
Page ParameterPage = (Page)System.Web.HttpContext.Current.Handler;
ParameterPage.RegisterStartupScript("confirm","<script language='JavaScript'>var retValue=window.confirm('"+str_Message+"');</script>");
}
/**//// <summary>
/// 服务器端弹出confirm对话框,询问用户准备转向那些操作,包括“确定”和“取消”时的操作
/// </summary>
/// <param name="str_Message">提示信息,比如:"成功增加数据,单击\"确定\"按钮填写流程,单击\"取消\"修改数据"</param>
/// <param name="btn_Redirect_Flow">"确定"按钮id值</param>
/// <param name="btn_Redirect_Self">"取消"按钮id值</param>
/// <param name="page">Page类</param>
public static void Confirm(string str_Message,string btn_Redirect_Flow,string btn_Redirect_Self)
{
Page ParameterPage = (Page)System.Web.HttpContext.Current.Handler;
ParameterPage.RegisterStartupScript("","<script> if (confirm('"+str_Message+"')==true){document.forms(0)."+btn_Redirect_Flow+".click();}else{document.forms(0)."+btn_Redirect_Self+".click();}</script>");
}
/**//// <summary>
/// 弹出confirm对话框-激活Botton的事件
/// </summary>
/// <param name="str_Message">提示信息,例子:"您是否确认删除!"</param>
/// <param name="btn">隐藏Botton按钮Id值,比如:btn_Flow</param>
public static void ConfirmMessage(string str_Message,string btn)
{
Page ParameterPage = (Page)System.Web.HttpContext.Current.Handler;
ParameterPage.RegisterStartupScript("confirm","<script> if(confirm('"+str_Message+"')==true){document.forms(0)."+btn+".click();}</script>");
}
#endregion
提示消息框#region 提示消息框
/**//// <summary>
/// 提示消息框
/// </summary>
/// <param name="str_Message">提示信息</param>
public static void prompt(string str_Message)
{
Page ParameterPage = (Page)System.Web.HttpContext.Current.Handler;
ParameterPage.RegisterStartupScript("prompt","<script language='JavaScript'>window.prompt('"+str_Message+"');</script>");
}
#endregion
}