2013-04-27 73 views
1

我有一個asp.net頁面與Ajax更新面板和網格。在同一個更新面板中,我有一個modalpopupextender。我想單擊網格的行按鈕來顯示modalpopupextender。顯示/隱藏modalpopupextender裏面updatepanel

我寫了這個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 

回答

0

我假設你已經解決了這個問題。我想你所缺少的是你的ModalPopupExtender是BehaviorID =「mpe」,然後在你的javascript中你將使用$ find('mpe').show();