写了个各种消息框的类

本文介绍了一个用于 ASP.NET 的消息弹窗类,该类实现了警告、确认及提示等不同类型的客户端 JavaScript 对话框,并提供了多种使用场景的方法。

写了个各种消息框的类,以后要用可直接调用了

None.gifpublic class Message
ExpandedBlockStart.gifContractedBlock.gif    
dot.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif        
警告消息框#region 警告消息框
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary> 
InBlock.gif        
/// 警告消息框
InBlock.gif        
/// </summary> 
ExpandedSubBlockEnd.gif        
/// <param name="str_Message">提示信息,例子:"不能为空!"</param> 

InBlock.gif        public static void Alert(string str_Message) 
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif
InBlock.gif            Page ParameterPage 
= (Page)System.Web.HttpContext.Current.Handler;
InBlock.gif            ParameterPage.RegisterStartupScript(
"alert","<script language='JavaScript'>alert('"+str_Message+"');</script>"); 
ExpandedSubBlockEnd.gif        }
 
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary> 
InBlock.gif        
/// 服务器端弹出alert对话框,并使控件获得焦点 
InBlock.gif        
/// </summary> 
InBlock.gif        
/// <param name="str_Ctl_Name">获得焦点控件Id值,比如:txt_Name</param> 
ExpandedSubBlockEnd.gif        
/// <param name="str_Message">提示信息,例子:"请输入您姓名!"</param> 

InBlock.gif        public static void Alert(string str_Ctl_Name,string str_Message) 
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif
InBlock.gif            Page ParameterPage 
= (Page)System.Web.HttpContext.Current.Handler;
InBlock.gif            ParameterPage.RegisterStartupScript(
"alert","<script language='JavaScript'>alert('"+str_Message+"');document.forms(0)."+str_Ctl_Name+".focus(); document.forms(0)."+str_Ctl_Name+".select();</script>"); 
ExpandedSubBlockEnd.gif        }
 
ExpandedSubBlockEnd.gif        
#endregion

InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif        
确认消息框#region 确认消息框
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 弹出confirm对话框-实现页面跳转 
InBlock.gif        
/// </summary>
InBlock.gif        
/// <param name="PageTarget">跳转到的页面</param>
ExpandedSubBlockEnd.gif        
/// <param name="Content">提示信息</param>

InBlock.gif        public static void Confirm(string PageTarget,string str_Message)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif           Page ParameterPage 
= (Page)System.Web.HttpContext.Current.Handler;
InBlock.gif            ParameterPage.RegisterStartupScript(
"confirm","<script language='JavaScript'>var retValue=window.confirm('"+str_Message+"');"+"if(retValue){window.location='"+PageTarget+"';}</script>");
ExpandedSubBlockEnd.gif        }

InBlock.gif        
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 弹出confirm对话框-提示信息
InBlock.gif        
/// </summary>
ExpandedSubBlockEnd.gif        
/// <param name="str_Message">提示信息</param>

InBlock.gif        public static void Confirm(string str_Message)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Page ParameterPage 
= (Page)System.Web.HttpContext.Current.Handler;
InBlock.gif            ParameterPage.RegisterStartupScript(
"confirm","<script language='JavaScript'>var retValue=window.confirm('"+str_Message+"');</script>");
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary> 
InBlock.gif        
///  服务器端弹出confirm对话框,询问用户准备转向那些操作,包括“确定”和“取消”时的操作 
InBlock.gif        
/// </summary> 
InBlock.gif        
/// <param name="str_Message">提示信息,比如:"成功增加数据,单击\"确定\"按钮填写流程,单击\"取消\"修改数据"</param> 
InBlock.gif        
/// <param name="btn_Redirect_Flow">"确定"按钮id值</param> 
InBlock.gif        
/// <param name="btn_Redirect_Self">"取消"按钮id值</param> 
ExpandedSubBlockEnd.gif        
/// <param name="page">Page类</param> 

InBlock.gif        public static void Confirm(string str_Message,string btn_Redirect_Flow,string btn_Redirect_Self) 
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif
InBlock.gif            Page ParameterPage 
= (Page)System.Web.HttpContext.Current.Handler;
InBlock.gif            ParameterPage.RegisterStartupScript(
"","<script> if (confirm('"+str_Message+"')==true){document.forms(0)."+btn_Redirect_Flow+".click();}else{document.forms(0)."+btn_Redirect_Self+".click();}</script>"); 
ExpandedSubBlockEnd.gif        }
 
InBlock.gif
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary> 
InBlock.gif        
/// 弹出confirm对话框-激活Botton的事件 
InBlock.gif        
/// </summary> 
InBlock.gif        
/// <param name="str_Message">提示信息,例子:"您是否确认删除!"</param> 
ExpandedSubBlockEnd.gif        
/// <param name="btn">隐藏Botton按钮Id值,比如:btn_Flow</param> 

InBlock.gif        public static void ConfirmMessage(string str_Message,string btn) 
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif
InBlock.gif            Page ParameterPage 
= (Page)System.Web.HttpContext.Current.Handler;
InBlock.gif            ParameterPage.RegisterStartupScript(
"confirm","<script> if(confirm('"+str_Message+"')==true){document.forms(0)."+btn+".click();}</script>"); 
ExpandedSubBlockEnd.gif        }

InBlock.gif
ExpandedSubBlockEnd.gif        
#endregion

InBlock.gif
ContractedSubBlock.gifExpandedSubBlockStart.gif        
提示消息框#region 提示消息框
ExpandedSubBlockStart.gifContractedSubBlock.gif        
/**//// <summary>
InBlock.gif        
/// 提示消息框
InBlock.gif        
/// </summary>
ExpandedSubBlockEnd.gif        
/// <param name="str_Message">提示信息</param>

InBlock.gif        public static void prompt(string str_Message)
ExpandedSubBlockStart.gifContractedSubBlock.gif        
dot.gif{
InBlock.gif            Page ParameterPage 
= (Page)System.Web.HttpContext.Current.Handler;
InBlock.gif            ParameterPage.RegisterStartupScript(
"prompt","<script language='JavaScript'>window.prompt('"+str_Message+"');</script>");
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif        
#endregion

ExpandedBlockEnd.gif    }

转载于:https://www.cnblogs.com/abc19830814/articles/486371.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值