开发者

ASP.NET AJAX $find always returns null in usercontrol

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" 
        BackgroundCssCl开发者_如何学运维ass="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!


Try to combine the ClientID with the $find method.

instead of

$find("modalInform") 

try this

$find('<%= modalInform.ClientID %>') 


I tried the below example and I also faced same error like $find was returning null. Later I realised, I missed the "BehaviorID="AutoCompleteEx"" attributes.

http://forums.asp.net/t/1323927.aspx

And in the $find("AutoCompleteEx") method worked like a charm.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜