[英]Open a ModalPopupExtender on an UpdatePanel using javascript
[英]show/hide modalpopupextender inside updatepanel
我有一個帶有ajax updatepanel和一個網格的asp.net頁面。 在同一updatepanel中,我有一個modalpopupextender。 我想在單擊網格的行按鈕時顯示modalpopupextender。
我寫了這個js:
function AddRemoveFavorites(regId) {
Showpopup();
return false;
}
function Hidepopup() {
$find('ModalPopupExtender1').hide();
}
//Function to Show ModalPopUp
function Showpopup() {
$find('ModalPopupExtender1').show();
}
這是更新面板,modalpopup和gridview按鈕列的標記。
<asp:UpdatePanel ID="ResultUpdatePanel" runat="server" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="SearchLinkButton" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="SubmitButton" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" />
<ajax:ModalPopupExtender ID="ModalPopupExtender1" runat="server" CancelControlID="btnCancel"
OkControlID="btnOkay" TargetControlID="Button1" PopupControlID="Panel1" PopupDragHandleControlID="PopupHeader"
Drag="true" BackgroundCssClass="ModalPopupBG">
</ajax:ModalPopupExtender>
<asp:Panel ID="Panel1" Style="display: none" runat="server">
<div class="HellowWorldPopup">
<div class="PopupHeader" id="PopupHeader">
Header</div>
<div class="PopupBody">
<p>
This is a simple modal dialog</p>
</div>
<div class="Controls">
<input id="btnOkay" type="button" value="Done" />
<input id="btnCancel" type="button" value="Cancel" />
</div>
</div>
</asp:Panel>
和網格列
<asp:TemplateField HeaderStyle-CssClass="gridTitleCor2" ItemStyle-CssClass="GridBorderR"
ItemStyle-Wrap="false">
<ItemTemplate>
<asp:PlaceHolder ID="SavedPH" runat="server" Visible='<%# Eval("IsSaved").ToString() == "1" %>'>
<a href='#' onclick='AddRemoveFavorites(<%# Eval("RegistrantID").ToString() %>); return false;'
title="<%= Resources.UserProfile.C_SerRes_RemoveFavorites %>">
<img id='<%# String.Format("StatusImage_{0}", Eval("RegistrantID").ToString()) %>'
src="/Images/StarYellow.png" />
</a></asp:PlaceHolder>
<asp:PlaceHolder ID="NotSavedPH" runat="server" Visible='<%# Eval("IsSaved").ToString() == "0" %>'>
<a href='#' onclick='AddRemoveFavorites(<%# Eval("RegistrantID").ToString() %>); return false;'
title="<%= Resources.UserProfile.C_SerRes_AddFavorites %>">
<img id='<%# String.Format("StatusImage_{0}", Eval("RegistrantID").ToString()) %>'
src="/Images/StarGrey.png" />
</a></asp:PlaceHolder>
</ItemTemplate>
</asp:TemplateField>
但我收到以下錯誤:
Uncaught TypeError: Cannot call method 'show' of null
我認為您已經解決了問題。
我認為您在ModalPopupExtender上缺少的是BehaviorID =“ mpe”,那么在您的JavaScript中,您將使用$ find('mpe')。show();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.