Hello,
I'm trying to put a webdialog on a user control (.ascx) and then use that in a .aspx page. The $find method fails to find the webdialog when I call it like so:
<input type="button" value="Show (Client Side)" onclick="$find('confirmDelete').show();" />
"confirmDelete" is the name of my web dialog. I have another page pretty much identical except that all the code that's in the ascx control, is right on the .aspx page and it works fine.
-Eric
I'm not sure, but it could be that the web dialog's name is different when rendered to the page since it's within another control.. I'd recommend you to take a look at the generated code (right click on the page and then 'View source code' trying to find out what the name of the web dialog is.
I ran the solution in VS and then opened TestCallingTestWebDialogControl.aspx in Script Documents/Windows Internet Explorer
Looks like it might be "incTestWebDialog_confirmDelete_clientState"
<input type="hidden" id="incTestWebDialog_confirmDelete_clientState" name="incTestWebDialog_confirmDelete_clientState" /><div class="ig_Control igdw_Control :=CtlMain:layout" id="incTestWebDialog_confirmDelete" style="height:300px;width:400px;overflow:hidden;position:absolute;display:none;visibility:hidden;">
I also saw the following script:
<script type="text/javascript"> //<![CDATA[ Sys.WebForms.PageRequestManager._initialize('incTestWebDialog$ScriptManager1', document.getElementById('aspnetForm')); Sys.WebForms.PageRequestManager.getInstance()._updateControls([, [, [, 90); //]]> </script>
I then get an error "'null' is null or not an object" when I click on:
Based on what you said, I tried adding a watch for $find("incTestWebDialog_confirmDelete_clientState") and $find("incTestWebDialog$ScriptManager1") and they were both null also.
Rumen,
I wasn't able to get this syntax to work. My .ascx code looks like:
<form id="frmMyForm" runat=server> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <cc1:WebDialogWindow ID="confirmDelete" runat="server" Height="300px" Width="400px" WindowState="Hidden" Modal="True"> <ContentPane> <Template> <asp:Label ID="deleteMessage" runat="server" Text="Label"></asp:Label> </Template> </ContentPane> </cc1:WebDialogWindow></form> I've set a breakpoint in my javascript and have tried various versions of the $find method in the immediate pane:
$find('<%= deleteMessage %>')$find('<%= confirmDelete %>')$find('<%= deleteMessage.confirmDelete %>')$find('<%= frmMyForm.deleteMessage.confirmDelete %>')$find('<%= confirmDelete.ClientID %>')
They all return null.
The only way I get get a value is the confirmDelete webdialog is by:
$find('incAttachments1_confirmDelete')
This is the name of the control from doing a view source.
The general problem is that ASP.NET AJAX expects the client-side ID of the control and in the case of nested controls inside Templates (or in fact, any other INamingContainer), so you can use the following syntax instead of hardcoding the client id (there is not guarantee that the ID will be the same if you add other controls on the page)
e.g.
$find('<%= confirmDelete.ClientID %>').
I looked a little further down the page and saw:
<script type="text/javascript">//<![CDATA[Sys.Application.initialize();Sys.Application.add_init(function() { $create(Infragistics.Web.UI.WebDialogWindow, {"id":"incTestWebDialog_confirmDelete","name":"confirmDelete","props":[[[,3,,,"400px","300px",,,,1,,0],{"c":{"uid":"incTestWebDialog$confirmDelete","buts":"7igdw_ModalBackground","mbc":"igdw_ModalBackground"}}],[[[[,,,]],[[[[,{"c":{"s":"i","a":"Close","h":"/ig_res/Default/images/igdw_CloseHover.gif","i":"/ig_res/Default/images/igdw_Close.gif","p":"/ig_res/Default/images/igdw_CloseMouseDown.gif"}}],,],[[[],,],[[[],,]],],[[[,,,,]],,]],,[]}, null, null, $get("incTestWebDialog_confirmDelete"));});//]]></script>
So on TestWebDialog.ascx I changed my input button to:
<input type="button" value="Show (Client Side)" onclick="$find('incTestWebDialog_confirmDelete').show();" />
and it worked!
Thanks,
Eric