ModalPopupExtender作为状态框
本文关键字:状态 ModalPopupExtender | 更新日期: 2023-09-27 18:15:45
我有一个ModalPopupExtender,我只是想使用作为一个状态弹出时,有一个长时间运行的后台任务。
<script language="javascript" type="text/javascript">
function ShowInfoPopup(Caption, Message) {
$find("<%= tcPopUpCaption.ClientID %>").innerHTML = Caption;
$find("<%= tcPopUpMessage.ClientID %>").innerHTML = Message;
$find("<%= mpe.ClientID %>").Show();
}
</script>
<asp:LinkButton runat="server" ID="btnPopup" />
<asp:Panel ID="pnlInfoPopup" runat="server" Style="display: none;"
Width="350px" CssClass="InfoPopup_Panel">
<asp:Table ID="Table1" runat="server" CssClass="InfoPopup_Layout"
Style="margin-bottom: 0px">
<asp:TableRow CssClass="InfoPopup_ActionRow">
<asp:TableCell BorderStyle="None">
<asp:Button ID="btnClose" runat="server" Text="x"
ToolTip="Close" BorderStyle="Outset"
UseSubmitBehavior="false" OnCommand="doCommand"
CommandName="ClosePopUp" />
</asp:TableCell>
</asp:TableRow>
<asp:TableHeaderRow Style="border-bottom: thick solid white">
<asp:TableHeaderCell ID="tcPopUpCaption" Width="100%"
BorderStyle="None" runat="server"
Text="Popup Caption" />
</asp:TableHeaderRow>
<asp:TableRow>
<asp:TableCell Width="50%" BorderStyle="None" runat="server"
ID="tcPopUpMessage" ClientIDMode="Static"
Text="Popup Message" />
</asp:TableRow>
</asp:Table>
</asp:Panel>
<asp:ModalPopupExtender ID="mpe" runat="server" PopupControlID="pnlInfoPopup"
BackgroundCssClass="mpeBackground" DropShadow="true"
TargetControlID="btnPopup" />
<asp:Button ID="btnS" runat="server" Text="Send" OnCommand="doCommand"
CommandName="send" UseSubmitBehavior="false" Width="100px"
Height="45px" ClientIDMode="Static"
OnClientClick="ShowInfoPopup('Please wait...', 'Sending...')" />
<asp:Button ID="btnL" runat="server" Text="Load" OnCommand="doCommand"
CommandName="load" UseSubmitBehavior="false" Width="100px"
Height="45px" ClientIDMode="Static"
OnClientClick="ShowInfoPopup('Just a sec...', 'Loading...')" />
当用户点击其中一个按钮时(这只是一个示例场景),它会显示带有相关标题和消息的弹出框,然后执行正常的Postback来执行(长)任务。
然而,在"ShowInfoPopup"脚本中,$find的标题和消息失败,因为它找不到控件,它返回NULL。
欢迎有任何建议
使用$get
代替$find
来获取DOM元素的引用。$find
只能用于获取客户端javascript对象的引用