views:

37

answers:

1

I want to use multiple targets with my ModalPopUp extender. One of my buttons is set as target in the ModalPopup and the other one will use server-side code to show the ModalPopup.

This is my ModalPopup so far:

<msAjax:ModalPopupExtender ID="modalInform" runat="server" 
        BehaviorID="modalInform" 
        TargetControlID="btnSearchUsers" 
        PopupControlID="pnlInform" 
        RepositionMode="RepositionOnWindowResize" 
        BackgroundCssClass="modalWindow"
        OkControlID="linkCloseInform" />

Then I found this little tutorial on the ASP.NET AJAX site. But when I use $find("modalInform") in the pageLoad Javascript function (as defined in the tutorial at the bottom), I'm always getting a $find("modalInform") is null error.

This code is included in a usercontrol, the usercontrol is used in a ASPX page and this ASPX-page uses a MasterPage. I've noticed that if I'm using

<%= modalInform.ClientID %>

I'm getting a different value then defined in my HTML-source (propably because of the MasterPage?).

Does somebody know what the problem could be?

Thanks in advance!

+2  A: 

Try to combine the ClientID with the $find method.

instead of

$find("modalInform") 

try this

$find('<%= modalInform.ClientID %>') 
Tim Schmelter
Already tried it without success...
thomasvdb
What error do you get? Is $find('<%= modalInform.ClientID %>') null or is the function not defined? Do you have Scriptmanager/ScriptmanagerProxy registered?
Tim Schmelter
Error: $find("ctl00_contentHolder_propDocument_modalInform") is nullI've added a ScriptManager in my MasterPage.
thomasvdb
Is documentGetElementById('<%= modalInform.ClientID %>') null too?
Tim Schmelter
Sorry, misspelled: document.getElementById('<%= modalInform.ClientID %>').Is there a difference between the value from $find or document.getElementbyid and the real id in your generated html file?
Tim Schmelter
It is, the value with document.getElementById is also null! Has this something to do because I'm using this in a usercontrol?
thomasvdb
You havent answered my last question. What is the id in the generated html file? If you're using jQuery you can also find your control with $("[id$=modalInform]")The ID will change for every control what is inside an NamingContainer(UserControl,Gridview,etc), but ClientID property should take that into account.
Tim Schmelter
$find and document.getElementById both return null. As a test I've set alert("<%= modalInform.ClientID %>"); and the ID I get here is the same as in my HTML-code...
thomasvdb
That must have something to do with the time your script is executed.Why cant you just use the Show method of the extender?
Tim Schmelter
Also having trouble with calling the Show-method... I'll try to extract the ModalPopup to a seperate page. Maybe something is blocking my ModalPopup. Thanks for the quick responses and help!
thomasvdb
Found the problem... somewhere along in the code the OkControl was set to Visible="false"... unbelievable how much time I lost with this. Thanks again Tim!
thomasvdb