2009-12-17 20 views
0

我有一個頁面,我有一個ModalPopUpExtender,我想從代碼中顯示。ASP.NET Ajax查找組件問題

這是我的地盤結構,它是一個嵌套的母版中的Web表單:

... 
    <asp:Content ID="con" ContentPlaceHolderID="mainContent" runat="server"> 
     <asp:MultiView ID="tabMultiView" runat="server"> 
      <asp:View ID="generalTab" runat="server"> 
       <asp:ScriptManager ID="scriptManager" runat="server"> 
       </asp:ScriptManager> 

       <ajaxToolkit:ModalPopupExtender ID="newAddressModalPopup" CancelControlID="newAddressDialogCancelButton" 
        BackgroundCssClass="modalBackground" TargetControlID="newAddressLink" PopupControlID="newAddressDialogDiv" 
        runat="server"> 
       </ajaxToolkit:ModalPopupExtender> 
       ... 

       <a href="" onclick="openNewAddressDialog()">open dialog</a> 

       <script type="text/javascript"> 


        function openNewAddressDialog() { 
         $find('<%= newAddressModalPopup.ClientID %>').show(); 
        } 
       </script> 
... 

find方法總是返回null。我也嘗試過findComponent等,它始終爲空。當我調試該方法時,我注意到組件集合(這是一種以控件ID爲鍵的字典)是空的。

還有什麼問題呢?順便說一句,我也在頁面上使用jQuery的東西。

非常感謝!

回答

0

好吧,我發現它。 TargetControl未在HTML中呈現,因爲它在另一個視圖中。

0

在您的JavaScript函數中嘗試使用document.getElementById("ctl00_ContentPlaceHolder1_newAddressModalPopup")。也許它有效。讓我知道你是否遇到問題。

或嘗試設置BehaviorID="someid"的模式popupextender和使用JavaScript代碼:

function changeValue() 
{ 
    var myBehavior = $find("myBehavior1"); 
    myBehavior.show(); 
} 

或者:

var modalDialog = $find("newAddressModalPopup"); 
// Get reference to modal popup using the Ajax API $find() function. 

if (modalDialog != null) { 
    modalDialog.show(); 
} 
+0

這兩種解決方案都無法正常工作......我是否必須爲腳本管理器設置任何特殊的功能?或者,jQuery分散了Asp AJAX的東西? – Chris 2009-12-17 11:12:20

+0

hai chris嘗試第三個.. – 2009-12-17 11:33:31

+0

chris BehaviorID =「newAddressModalPopup」與您的模態彈出式菜單的ID相同 – 2009-12-17 11:35:43