我的母版页上有一个带有ajax ModalPupupExtender的面板,我希望能够在所有内容页面上显示。当所有相关代码都在内容页面上时,一切正常。当我将标记和代码移到母版页后,我的弹出窗口不会弹出。听到一些代码:
...
<body>
<form runat="server">
<asp:ScriptManager runat="server" EnablePartialRendering="true">
<Scripts>
<asp:ScriptReference Name="jquery" />
<asp:ScriptReference Name="jquery.ui.combined" />
</Scripts>
</asp:ScriptManager>
...ext...
<%-- invisible button for TargetControlID property --%>
<asp:Button Style="display:none" ID="UselessButton" runat="server" Text="I am useless"/>
<%-- popup --%>
<asp:Panel style="width: 500px; display: none" ID="WarningMessageBoxPanel" runat="server" CssClass="popup">
<asp:Panel runat="Server" ID="WarningPopupDragHandle" CssClass="popupDragHandle">
<asp:Image ID="WariningIcon1" runat="server" CssClass="centerImage" ImageUrl="~/Images/messageBox_ExclamationMark.jpg" />
</asp:Panel>
<br />
<div class=" warningDiv requiredMedium">
<asp:Label ID="WarningMessage" runat="server" Text="placeholder message"></asp:Label>
</div>
<div style="text-align:center;">
<asp:Button ID="OKButton" runat="server" Text="OK"/>
</div>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="WarningMessageBoxPopupExtender" runat="server"
BehaviorID="WarningMessageBoxPopupExtender" TargetControlID="UselessButton"
PopupControlID="WarningMessageBoxPanel" OkControlID="OKButton" DropShadow="true" Drag="true"
PopupDragHandleControlID="WarningPopupDragHandle">
</ajaxToolkit:ModalPopupExtender>
</form>
</body>
</html>
public void ShowWarningBox(String message)
{
WarningMessage.Text = message;
WarningMessageBoxPopupExtender.Show();
}//end ShowWarningBox()
在内容页面上,我的标题靠近标记顶部:
<%@ MasterType VirtualPath="~/Site.Master" %>
然后,我应该可以从具有上述标题showWarningBox()
的任何内容页面调用Master.ShowWarningBox()
。该函数正在调用,但弹出窗口没有显示。
答案 0 :(得分:0)
试试这个:
Site siteObj = this.Master as Site;