ASP.NET中的弹出信息对话框类

本文介绍了一个自定义Alert类的各种用法,包括简单的警告框显示、带确认的选择框、以及结合不同页面跳转逻辑的复杂应用。该类通过生成内联JavaScript代码实现多种交互方式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

None.gifpublic class Alert
ExpandedBlockStart.gifContractedBlock.gif
dot.gif{
InBlock.gif    
private string alert;
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// 弹出窗口并返回到前一页面
InBlock.gif    
/// </summary>
ExpandedSubBlockEnd.gif    
/// <param name="m">提示信息内容</param>

InBlock.gif    public Alert(string m)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
this.alert = "<script>alert('" + m + "');histroy.back(-1);</script>";
ExpandedSubBlockEnd.gif    }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// 弹出窗口
InBlock.gif    
/// </summary>
InBlock.gif    
/// <param name="m">提示信息内容</param>
ExpandedSubBlockEnd.gif    
/// <param name="j">无意义,只是增加参数</param>

InBlock.gif    public Alert(string m, int j)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
this.alert = "<script>alert('" + m + "');</script>";
ExpandedSubBlockEnd.gif    }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// 弹出窗口并重定向到其它页面
InBlock.gif    
/// </summary>
InBlock.gif    
/// <param name="m">提示信息内容</param>
ExpandedSubBlockEnd.gif    
/// <param name="u">重定向到的页面</param>

InBlock.gif    public Alert(string m, string u)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
this.alert = "<script>alert('" + m + "');window.location.href='" + u + "';</script>";
ExpandedSubBlockEnd.gif    }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// 弹出选择窗口,点击“是”重定向到一个页面,选择“否”无操作
InBlock.gif    
/// </summary>
InBlock.gif    
/// <param name="m">提示信息内容</param>
InBlock.gif    
/// <param name="u">点击“是”时重定向到的页面</param>
ExpandedSubBlockEnd.gif    
/// <param name="j">无意义参数</param>

InBlock.gif    public Alert(string m, string u, int j)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
this.alert = "<script>if(confirm('" + m + "')==true) {window.location.href('" + u + "'); } else {} ;</script>";
ExpandedSubBlockEnd.gif    }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// 弹出选择窗口,点击“是”重定向到一个页面,点击“否”重定向到另一个页面
InBlock.gif    
/// </summary>
InBlock.gif    
/// <param name="m">弹出信息内容</param>
InBlock.gif    
/// <param name="u">点击“是”时重定向到的页面</param>
ExpandedSubBlockEnd.gif    
/// <param name="u1">点击“否”时重定向到的页面</param>

InBlock.gif    public Alert(string m, string u, string u1)
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        
this.alert = "<script>if(confirm('" + m + "')==true) {window.location.href('" + u + "'); } else {window.location.href('" + u1 + "');} ;</script>";
ExpandedSubBlockEnd.gif    }

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif    
/**//// <summary>
InBlock.gif    
/// 输出到页面
ExpandedSubBlockEnd.gif    
/// </summary>

InBlock.gif    public void show()
ExpandedSubBlockStart.gifContractedSubBlock.gif    
dot.gif{
InBlock.gif        System.Web.HttpContext.Current.Response.Write(
this.alert);
ExpandedSubBlockEnd.gif    }

ExpandedBlockEnd.gif}

转载于:https://www.cnblogs.com/hzuIT/archive/2007/06/12/780681.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值