共享相同的ModalPopupExtender [英] Sharing the same ModalPopupExtender
本文介绍了共享相同的ModalPopupExtender的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在一个简单的aspx页面中,我有两个按钮(Btn1和Btn2),其中有两个面板(Panel1和Panel2)和一个modalpopextender(mpe1).每个按钮都位于每个面板的正下方.
然后,我将在底部看到mpe.问题,这些按钮及其面板之间是否可能共享mpe(是/否),如果是,我该如何为mpe编码targetcontrolid和popupcontrolid,而不是为上面的每个控件分配2个mpe .
Hi ,in a simple aspx page I have two buttons (Btn1 & Btn2) with two panels (Panel1 & Panel2) and a modalpopextender (mpe1).Each button is directly beneath each panel.
Then I have the mpe at the bottom. Question, Is it possible that the mpe is shared between these buttons and their panels (Y/N), If Yes how do i code the targetcontrolid and the popupcontrolid for the mpe instead of having 2 mpe''s for each of the controls above.
推荐答案
It worked!!! Thanks alot richcb.
Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!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>
<style type="text/css">
.modalBackground
{
background-color: #161616;
filter: alpha(opacity=80);
opacity: 0.8;
}
.modalPopup
{
background-color: #FFFFFF;
border-width: 3px;
border-style: solid;
border-color: black;
padding-top: 10px;
padding-left: 10px;
width: 300px;
height: 170px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button 1" OnClick="Button1_Click" />
<asp:Panel ID="Panel1" runat="server" style="display:none">
This is Panel 1
<asp:Button ID="Button2" runat="server" Text="Button 2" OnClick="Button2_Click" />
<asp:Panel ID="Panel2" runat="server" style="display:none">
This is Panel 2
<asp:HiddenField ID="HiddenField1" runat="server" />
<asp:HiddenField ID="HiddenField2" runat="server" />
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" PopupControlID="HiddenField1" TargetControlID="HiddenField2" BackgroundCssClass="modalBackground" >
</div>
</form>
</body>
</html>
Default.aspx.cs:
protected void Button1_Click(object sender, EventArgs e)
{
ModalPopupExtender1.TargetControlID = Button1.ID;
ModalPopupExtender1.PopupControlID = Panel1.ID;
ModalPopupExtender1.Show();
}
protected void Button2_Click(object sender, EventArgs e)
{
ModalPopupExtender1.TargetControlID = Button2.ID;
ModalPopupExtender1.PopupControlID = Panel2.ID;
ModalPopupExtender1.Show();
}
这篇关于共享相同的ModalPopupExtender的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文