首先要加AjaxControlToolkit.dll的引用

前台

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PopupExample.aspx.cs" Inherits="test1._7.PopupExample" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>弹出例子</title>
    <link href="css/Popup.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager" runat="server">
    </asp:ScriptManager>
    <div>
        <asp:LinkButton runat="server" ID="lkb_TcDiv" Text="弹出测试" OnClick="lkb_TcDiv_Click"></asp:LinkButton>
    </div>
    <div>
        <asp:Button ID="btnPopUp" runat="server" OnClick="btnPopUp_Click" Style="display: none" />
        <div id="divModalPopupSend" style="display: none;">
            <asp:Panel ID="Panel1" runat="server" Style="height: 450px; width: 650px; text-align: left;"
                CssClass="ModalPopupCss">
                <div>
                    <asp:TextBox runat="server" ID="txt"></asp:TextBox>
                    <asp:Button runat="server" ID="btnSave" Text="保存" OnClick="btnSave_Click" />
                    <asp:Button ID="ButtonCloce" runat="server" Text="关闭" />
                </div>
            </asp:Panel>
        </div>
        <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" BackgroundCssClass="modalBackground"
            DropShadow="True" DynamicServicePath="" Enabled="true" PopupControlID="Panel1"
            TargetControlID="btnPopUp" CancelControlID="ButtonCloce">
        </cc1:ModalPopupExtender>
    </div>
    </form>
</body>
</html>

后台

using System;

namespace test1._7
{
    public partial class PopupExample : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void GetShowPopUp(String pName, String pID, Object sender, EventArgs e)
        {
            btnPopUp_Click(sender, e);
        }

        protected void btnPopUp_Click(object sender, EventArgs e)
        {
            ModalPopupExtender1.Enabled = true;
            ModalPopupExtender1.Show();
        }

        protected void lkb_TcDiv_Click(object sender, EventArgs e)
        {
            GetShowPopUp("text1", "222", sender, e);
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            MessageBox.MsgBox("sss");
        }
    }
}

css

.modalBackground 
{
    background-color:Gray;
    filter:alpha(opacity=70);
    opacity:0.7;  
}
.ModalPopupCss
{
    vertical-align:middle;
    width:50;
    background:white;
    border:solid 2px gray;
    text-align:center;
    padding:10px 10px 10px 10px;
    font-size:large; 
    font-weight:bold;
    color:Black;
}

 

 

posted on 2013-01-09 10:35  蜜茶  阅读(206)  评论(0)    收藏  举报