1

我有一个带有 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 
4

2 回答 2

2

我在这里找到了答案:

http://www.jonathanjungman.com/blog/post/Hiding-ASPNET-Ajax-Modal-Popup-Dialog-Using-JavaScript.aspx

希望它会在某个时候帮助某人

于 2013-04-27T10:51:33.013 回答
0

我假设你已经解决了这个问题。

我认为您在 ModalPopupExtender 上缺少的是 BehaviorID="mpe",然后在您的 javascript 中您将使用 $find('mpe').show();

于 2016-06-01T13:46:40.617 回答