您的位置:首页 > 编程语言 > ASP

ASP.NET 用户控件实现后台确认提醒框

2016-05-19 11:42 711 查看
效果图



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();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: