ASP.NET 用户控件实现后台确认提醒框
2016-05-19 11:42
711 查看
效果图
CSS
winOKOrCancel.ascx
aspx调用
CSS
/** *createTime:二〇一六年五月十九日 *author:ChinaLzw *Description:确认提醒框样式 **/ .mall-dialog{font: 12px/1.5 tahoma,arial,Hiragino Sans GB,宋体,sans-serif;} .mall-dialog button, input, select, textarea {font: 12px/1.5 tahoma,arial,'Hiragino Sans GB',宋体,sans-serif;} .mall-dialog{font-family: sans-serif;-webkit-text-size-adjust: 100%;} .mall-dialog .tm-dialog-mask {position: fixed;top: 0;right: 0;left: 0;bottom: 0;background-color: #373737;background-color: rgba(55,55,55,.1);height: 100%;z-index: 1000;filter: alpha(opacity=90);} .mall-dialog .tm-dialog {outline: none;position: absolute;left: -9999px;top: -9999px;z-index: 1000;} .mall-dialog .tm-dialog-content {position: relative;height: 100%;background-color: #fff;border: none;border-radius: 6px 6px;background-clip: padding-box;outline: 0;} .mall-dialog .tm-dialog-body {box-sizing: border-box;height: 100%;padding: 16px;} .mall-dialog .confirm-mod_container {min-width: 360px;background-color: #fff;} .mall-dialog .confirm-mod_header {font-size: 14px;} .mall-dialog .confirm-mod_body {padding: 15px 0 25px;} .mall-dialog .confirm-mod_footer {text-align: center;} .mall-dialog button::-moz-focus-inner, input::-moz-focus-inner {border: 0;padding: 0;} .mall-dialog .button-mod_button.button-mod_secondary {background-color: #66b6ff;color: #fff;border: 1px solid #66b6ff;} .mall-dialog .confirm-mod_button {margin: 0 6px;} .mall-dialog .button-mod_button {box-sizing: border-box;display: inline-block;border: none;height: 28px;line-height: 26px;padding: 0 12px;border-radius: 3px;cursor: pointer;text-decoration: none;} .mall-dialog blockquote, body, button, dd, dl, dt, fieldset, form, h1, h2, h3, h4, h5, h6, hr, input, legend, li, ol, p,pre, td, textarea, th, ul {margin: 0;padding: 0;} .mall-dialog [type="reset"], [type="submit"], button, html [type="button"] {-webkit-appearance: button;} .mall-dialog [type="button"], [type="reset"], [type="submit"], button {cursor: pointer;} .mall-dialog button, select {text-transform: none;} .mall-dialog button, input, select, textarea {margin: 0;} .mall-dialog button, input, select {overflow: visible;} .mall-dialog button, input, select, textarea {font: inherit;} .mall-dialog button, input, select, textarea {font-size: 100%;} .mall-dialog blockquote, body, button, dd, dl, dt, fieldset, form, h1, h2, h3, h4, h5, h6, hr, input, legend, li, ol, p,pre, td, textarea, th, ul {margin: 0;padding: 0;} .mall-dialog .confirm-mod_footer {text-align: center;} .mall-dialog .button-mod_button.button-mod_grey {background-color: #6c6c6c;color: #fff;border: 1px solid #6c6c6c;} .mall-dialog .confirm-mod_button {margin: 0 6px;} .mall-dialog .button-mod_button {box-sizing: border-box;display: inline-block;border: none;height: 28px;line-height: 26px;padding: 0 12px;border-radius: 3px;cursor: pointer;text-decoration: none;}
winOKOrCancel.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="winOKOrCancel.ascx.cs" Inherits="ICM.Web.Leather.UserControl.Common.winOKOrCancel" %> <asp:Panel ID="plMallDialog" runat="server"> <div class="mall-dialog"> <div class="tm-dialog-container"> <div class="tm-dialog-wrap"> <div class="tm-dialog-mask"></div> <div style="position: fixed; left: 25%; top: 20%;" class="tm-dialog " tabindex="0" role="dialog"> <div class="tm-dialog-content"> <div class="tm-dialog-body"> <div class="confirm-mod_container"> <div class="confirm-mod_header"> <asp:Literal ID="ltrTitle" runat="server"></asp:Literal> </div> <div class="confirm-mod_body"> <asp:Literal ID="ltrMessage" runat="server"></asp:Literal> </div> <div class="confirm-mod_footer"> <asp:Button ID="btnOK" runat="server" Text="确定" CssClass="button-mod_button button-mod_secondary confirm-mod_button" OnClick="btnOK_Click" /> <asp:Button ID="btnCancel" runat="server" Text="关闭" CssClass="button-mod_button button-mod_grey confirm-mod_button" OnClick="btnCancel_Click"/> </div> </div> </div> </div> </div> </div> </div> </div> </asp:Panel>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace ICM.Web.Leather.UserControl.Common { public partial class winOKOrCancel : System.Web.UI.UserControl { public delegate void EventDelegate(bool result);//定义委托 public event EventDelegate ClickEvent;//定义点击事件 protected void Page_Load(object sender, EventArgs e) { } /// <summary> /// 弹出确认框 /// </summary> /// <param name="Title">标题</param> /// <param name="Message">提醒内容</param> internal void Show(string Title, string Message) { this.plMallDialog.Visible = true; this.ltrTitle.Text = Title; this.ltrMessage.Text = Message; } /// <summary> /// 隐藏提示框 /// </summary> internal void Hide() { this.plMallDialog.Visible = false; } /// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnOK_Click(object sender, EventArgs e) { this.Hide(); if (ClickEvent != null) { ClickEvent(true); } } /// <summary> /// 关闭 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnCancel_Click(object sender, EventArgs e) { this.Hide(); if (ClickEvent != null) { ClickEvent(false); } } } }
aspx调用
<%@ Register Src="~/UserControl/Common/winOKOrCancel.ascx" TagPrefix="uc1" TagName="winOKOrCancel" %>
<uc1:winOKOrCancel runat="server" ID="ucwinOKOrCancel" />
protected void Page_Load(object sender, EventArgs e) { this.ucwinOKOrCancel.ClickEvent += ucwinOKOrCancel_ClickEvent; this.ucwinOKOrCancel.Hide(); }
/// <summary> /// 删除订单 /// </summary> /// <param name="source"></param> /// <param name="e"></param> protected void rptOrders_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "Del") { this.ucwinOKOrCancel.Show("您确定要永久删除该订单吗?", "删除后,将无法找回。"); this.hidDelID.Value = e.CommandArgument.ToString(); } } /// <summary> /// 用户控件点击事件 /// </summary> /// <param name="result"></param> void ucwinOKOrCancel_ClickEvent(bool result) { if (result && this.hidDelID.Value != "-1") { MD.OrdersInfo model = new MD.OrdersInfo(); model.OrderID = Convert.ToInt32(this.hidDelID.Value); model.StatuID = 9; ODBL.Update(model); this.BindView(); } }
相关文章推荐
- 在ASP.NET 2.0中操作数据之七十一:保护连接字符串及其它设置信息
- 在ASP.NET 2.0中操作数据之七十:配置数据库连接和命令等级设置
- (1-1)文件结构的升级(Area和Filter知识总结) - ASP.NET从MVC5升级到MVC6
- ASP.NET MVC下的四种验证编程方式
- ASP.NET MVC验证 - 自定义验证规则、验证2个属性值不等【待验证】
- imageView的aspect fill枚举值
- 在ASP.NET 2.0中操作数据之六十九:处理Computed Columns列
- asp.net中使用基于角色role的Forms验证
- 在ASP.NET 2.0中操作数据之六十八:为DataTable添加额外的列
- ASP.NET MVC Controller的激活
- ASP.NET Word Excel PDF 预览
- 细说ASP.NET Forms身份认证
- 在ASP.NET 2.0中操作数据之六十七:在TableAdapters中使用JOINs
- Web软体安全
- 如何在pb中创建COM组件,并在asp中调用并返回结果集
- 在ASP.NET 2.0中操作数据之六十六:在TableAdapters中使用现有的存储过程
- asp.net core 使用EF7 Code First 创建数据库,同时使用命令创建数据库
- 在ASP.NET 2.0中操作数据之六十六:在TableAdapters中使用现有的存储过程
- 在ASP.NET 2.0中操作数据之六十七:在TableAdapters中使用JOINs
- 在ASP.NET 2.0中操作数据之六十八:为DataTable添加额外的列