我有一个带有 ajax updatepanel 和网格的 asp.net 页面。在同一个更新面板中,我有一个 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