我在同一个内容页面中使用了两个modalpopupextenders,问题是当我显示一个时,两个都显示在另一个上。
我对modalpopup和面板使用了不同的id,但问题仍然存在。
我正在使用母版页,我将我的modalpopup放在内容页面中。
任何想法。
以下是源代码:
<ajaxToolkit:ModalPopupExtender ID="mpeComment" runat="server" TargetControlID="btnHiddenComment"
PopupControlID="pnlComment" CancelControlID="Button1" OkControlID="btnHiddenComment"
BackgroundCssClass="modalBackground" PopupDragHandleControlID="CommentCaption"
Drag="True" DynamicServicePath="" Enabled="True">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="pnlComment" runat="server" Style="display: none; background-color: #f5f5f5;
border: solid 3px #B8B8B8;" Width="500px">
<asp:Panel ID="CommentCaption" runat="server" Style="padding-bottom: 10px; cursor: move;
height: 30px;">
<table class="content_titre" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top">
<asp:Label ID="lblTitre" runat="server"></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
<table class="modalComment" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" style="height: 80px;" align="center" valign="top">
<table>
<tr>
<td>
</td>
<td>
<span style="color: #F58076; font-size: 11px;">
<asp:Label ID="LblErreur" runat="server"></asp:Label></span>
</td>
</tr>
</table>
</td>
</tr>
<tr align="center">
<td align="center">
<asp:Button ID="btnHiddenComment" runat="server" Style="display: none" />
<asp:Button ID="Button1" runat="server" Style="display: none" />
</td>
<td align="center">
<div class="login_button" style="width: 100px;">
<asp:Button ID="btnCancelComment" runat="server" CausesValidation="False" Width="100px"
Text="OK" PostBackUrl="ValidationDOC.aspx" />
</div>
</td>
</tr>
</table>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="mpeDemandeAvalider" runat="server" TargetControlID="btnHiddenComment"
PopupControlID="pnlDemandeAvalider" CancelControlID="Button1" OkControlID="btnHiddenComment"
BackgroundCssClass="modalBackground" PopupDragHandleControlID="Panel1"
Drag="True" DynamicServicePath="" Enabled="True">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="pnlDemandeAvalider" runat="server" Style="display: none; background-color: #f5f5f5;
border: solid 3px #B8B8B8;">
<asp:Panel ID="Panel1" runat="server" Style="padding-bottom: 10px; cursor: move;
height: 30px;">
<table class="content_titre" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top">
<asp:Label ID="Label3" runat="server"></asp:Label>
</td>
</tr>
</table>
</asp:Panel>
<table class="modalComment" cellpadding="0" cellspacing="0">
<tr>
<td colspan="2" style="height: 80px;" align="center" valign="top">
<table>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td style="height: 27px">
<img alt="" src="../../Ressources/images/navig/puce-blue.gif" /><span
style="color: #133880; font-size: 11px;"> Statut :</span>
</td>
<td height="27px" align="left">
<asp:DropDownList ID="DDLstatutPopup" runat="server" AppendDataBoundItems="True">
<asp:ListItem Value="-1">.:: Veuillez sélectionner une action de validation ::.</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td style="height: 27px">
<img alt="" src="../../Ressources/images/navig/puce-blue.gif" /><span
style="color: #133880; font-size: 11px;"> Motif :</span>
</td>
<td height="27px">
<asp:TextBox ID="txtPopUpMotif" runat="server" TextMode="MultiLine" Width="730px"
Height="64px"></asp:TextBox>
</td>
</tr>
</table>
</td>
</tr>
<tr align="center">
<asp:Button ID="Button2" runat="server" Style="display: none" />
<asp:Button ID="Button3" runat="server" Style="display: none" />
<td align="center">
<div class="login_button" style="width: 100px;">
<asp:Button ID="btnPopUpOK" runat="server" CausesValidation="False" Width="100px"
Text="OK" OnClick="OnValidateMulti" PostBackUrl="ValidationDOC.aspx" />
</div>
</td>
<td align="center">
<div class="login_button" style="width: 100px;">
<asp:Button ID="btnPopUpAnnuler" runat="server" CausesValidation="False" Width="100px"
Text="Annuler" OnClick="OnCancel" />
</div>
</td>
</tr>
</table>
</asp:Panel>
有任何建议。?
答案 0 :(得分:2)
我认为你的问题是BehaviorID
。
对于ModalPopupExtender
这两个人,您应该指定唯一的BehaviorID
。 BehaviorID
必须针对多个ModalPopupExtender
希望它对你有所帮助。
答案 1 :(得分:1)
您需要解决方法。
将您的第二个扩展器设置为虚拟按钮。
<asp:Button ID="Button_dummy" Style="display: none" runat="server" Text="Button" />
<cc1:ModalPopupExtender ID="MDE_Edit" DropShadow="true" runat="server"
TargetControlID="Button_dummy"
PopupControlID="Panel_edit" BackgroundCssClass="popProfBack" />
然后在点击的按钮中显示它(所以没有dummmy按钮)你想要显示它:
MDE_Edit.Show();
答案 2 :(得分:0)
我会尝试更改
TargetControlID="btnHiddenComment"
第二个弹出扩展器到一个具有不同ID的新隐藏按钮。
否则两个扩展器都针对相同的控件
答案 3 :(得分:0)
我在同一页面上遇到过多个ModalPopupExtender控件的类似问题。最终我提出的解决方案是在我的母版页中只有一个ModalPopupExtender和相关的弹出控制面板。通过PopupControlID属性与ModalPopupExtender关联的面板包含一个标签控件,可以从代码中的其他区域引用该控件。每当我需要页面上的控件来调用弹出面板时,我只需让控件(按钮,图像等)从后面的代码中调用ModalPopupExtender的show方法。
例如,这是我在母版页中的扩展程序和面板的标记:
<asp:Button ID="btnPopupInvoker" runat="server" style="display: none" />
<asp:ModalPopupExtender ID="modalPopupExtender" runat="server"
OkControlId="btnPopupOk" TargetControlId="btnPopupInvoker"
PopupControlId="pnlPopup" BackgroundCssClass="modalPopupBG"/>
<% // Broken rules popup %>
<asp:panel class="popupConfirmation" ID="pnlPopup" style="display: none;" runat="server">
<div class="popupContainer">
<div class="popupTitleBar" id="divPopupHeader">
<div>
<asp:Label ID="lblPopupTitle" runat="server" />
</div>
</div>
<div class="popupBody">
<div>
<asp:Label ID="lblPopupBody" runat="server" />
</div>
</div>
<div class="popupButtons">
<div>
<asp:Button ID="btnPopupOk" runat="server" Text="Close" />
</div>
</div>
</div>
</asp:panel>
注意我如何使用这个虚拟按钮通过TargetControlId属性分配给扩展器:
<asp:Button ID="btnPopupInvoker" runat="server" style="display: none" />
这个按钮隐藏了他的css。按钮本身不做任何事情,除了作为扩展器正常运行所需的标记。
现在,这是我单击提交按钮后从代码调用的代码:
/// <summary>
/// Loops through all the broken rules and displays them in a popup panel.
/// </summary>
/// <param name="rules">Broken rules collection.</param>
protected void DisplayBrokenRules(BrokenRulesCollection rules)
{
Label titleLabel = Master.FindControl("lblPopupTitle") as Label;
if (titleLabel != null)
{
titleLabel.Text = Properties.StringLibrary.Label_BrokenRulesPopupTitle;
}
Label bodyLabel = Master.FindControl("lblPopupBody") as Label;
if (bodyLabel != null)
{
bodyLabel.Text = string.Empty;
foreach (BrokenRule rule in rules)
{
bodyLabel.Text += String.Concat(rule.Description, "<br />");
}
ModalPopupExtender mpe = Master.FindControl("modalPopupExtender") as ModalPopupExtender;
if (mpe != null)
{
mpe.Show();
}
}
}
使用这种方法,我可以通过从我页面上的各种控件访问/操作它来重用相同的ModalPopupExtender(和相关的弹出式cotnrol面板)。这也避免了多个ModalPopupExtender控件,这只会增加page.did的大小。
答案 4 :(得分:0)
这是我尝试的解决方案,它对我有用。
~/.screenrc
这是后端代码:
<cc1:toolkitscriptmanager id="ToolkitScriptManager1" runat="server">
</cc1:toolkitscriptmanager>
<asp:LinkButton ID="lnkDummy" runat="server"></asp:LinkButton>
<cc1:modalpopupextender id="ModalPopupExtender1" runat="server" backgroundcssclass="modalBackground"
behaviorid="mpe" cancelcontrolid="btnHide" popupcontrolid="pnlPopup" targetcontrolid="lnkDummy">
</cc1:modalpopupextender>
<!-- daftar-->
<asp:Panel ID="pnlPopup" runat="server" CssClass="col-xs-6" Style="display: none;">
<div class="modal-content">
<div class="modal-header">
<h4>Pendaftaran</h4>
</div>
<div class="modal-body" style="">
</div>
<div class="modal-footer">
<asp:Button ID="btnHide" runat="server" Cssclass="btn btn-danger" Text="Tutup" />
</div>
</div>
</asp:Panel>
<!-- daftar-->
<!-- Log masuk-->
<asp:Panel ID="panelLogmasuk" runat="server" CssClass="col-xs-6" Style="display: none;">
<div class="modal-content">
<div class="modal-header">
<h4>Log masuk</h4>
</div>
<div class="modal-body" style="">
log masuk
</div>
<div class="modal-footer">
<asp:Button ID="Button3" runat="server" Cssclass="btn btn-danger" Text="Tutup" />
</div>
</div>
</asp:Panel>