我有一个包含用户控件(.ascx)的ModalPopupExtender 我想通过使用用户控件(.ascx)中的按钮单击来关闭弹出窗口 我想在客户端(Jquery,Javascript)
进行ModalPopupExtender:
<asp:HiddenField ID="hidPopup" runat="server" />
<ajaxToolkit:ModalPopupExtender ID="Surface1ModulePopup" PopupControlID="divPopup"
runat="server" TargetControlID="hidPopup" CancelControlID="btnimageclose" >
</ajaxtoolkit:ModalPopupExtender>
<div id="divPopup" class="over_line" style="visibility:hidden;">
<div class="TxConsultPopUp_Window" style="background-color: #f2fbff; height: 235px;
width: 156px; border: 1 px solid #4490d2; margin-left: -140px; margin-top: 0px;">
<div class="forg_head">
<div class="head_txt" style="width: 119px; text-align: left;">
Surface Selections</div>
<div class="close_but" style=" width:26px;">
<asp:ImageButton ID="btnimageclose" runat="server" ImageUrl="images/close.png" OnClientClick="javascript:CloseWin();return false;" />
</div>
</div>
<asp:Panel ID="panel1" runat="server">
<UC1:Surface id="Surf1Surface" runat="server">
</UC1:Surface>
</asp:Panel>
</div>
</div>
要打开它,我已经使用过:
var modalPopupBehaviorCtrl = $find('<%=Surface1ModulePopup.ClientID %>');
modalPopupBehaviorCtrl.show();
var ScheduledTreatments = document.getElementById("divPopup");
ScheduledTreatments.style.visibility = "visible";
请帮助我在1天内等待回答。优先考虑专家请回答
答案 0 :(得分:1)
我在这里的第一个答案,所以手指交叉它适合你。
CancelControlID中使用的ID实际上是控件的整个路径(XPath)的子集,因此如果您扩展ID以包含usercontrol名称,并强制它具有静态名称,那么您可以参考它。
我们使用的ASP命名约定将其用美元符号($)分隔,因此您可以将CancelControlID="btnimageclose"
更改为CancelControlID=Surf1Surface$nameofyourbutton
。 (我相信您可以更改使用的内容,因此您需要检查您使用的渲染内容。)
您还需要在usercontrol
中的按钮上设置ClientIDMode=Static
属性
这适用于我,使用此代码:
ModalPopupExtender的定义:
<ajaxToolkit:ModalPopupExtender ID="showReferences" runat="server"
CancelControlID="ucShowACarersFeedback$CloseWindow" TargetControlID="reviewsButton"
PopupControlID="referencesPanel" BackgroundCssClass="ModalPopupBG">
弹出的面板
<asp:Panel CssClass="popupConfirmation" ID="referencesPanel" Style="display: none;"
runat="server">
<uc:ShowACarersFeedback runat="server" ID="ucShowACarersFeedback" />
</asp:Panel>
控件中的按钮usShowACarersFeedback
<asp:Button ID="CloseWindow" runat="server" Text="Close Feedback window" ClientIDMode=Static />