tags:

views:

31

answers:

2

I've got a page where I have a ModalPopUpExtender which I want to show from code.

This is my site structure which is a web form within a nested masterpage:

    ...
    <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>
...

The find method always returns null. I also tried findComponent, etc. It's always null. When I debugged the method I noticed that the components collection (which is kind of a dictionary with the control ID as key) is empty.

What could the problem be? BTW, I am using jQuery stuff on the page as well.

Thanks a lot!

A: 

In your JavaScript function try using document.getElementById("ctl00_ContentPlaceHolder1_newAddressModalPopup"). Maybe it works. Let me know if you get issues.

Or try Setting BehaviorID="someid" to the modal popupextender and use this JavaScript code:

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

Or:

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

 if (modalDialog != null) {
     modalDialog.show();
 }
Pandiya Chendur
Neither of the two solutions are working... Do I have to setup anything special with the script manager maybe? Or does jQuery distract the Asp AJAX stuff?
Chris
hai chris try the third one..
Pandiya Chendur
chris BehaviorID="newAddressModalPopup" same as Id of your modal popup
Pandiya Chendur
A: 

Ok I found it. The TargetControl was not rendered in HTML because it was in another view.

Chris