I need to show/hide a dialog window on page load based on a cookie value. The $find function fails with 'null' is null or not an object.
Anyone done this? It seems like it should be pretty common.
Update after reviewing the forum: WebDialogWindow.initialize won't run when the design-time windowstate is hidden; and if the design time window state is normal, if i try to hide the window in the initialize function, it still flashes visible briefly before hiding - which is not acceptable behavior. Thanks in advance.
Hi,
It was planned to add another ClientEvent which would be raised within "initialize/constructor" function in addition to event raised when control is fully initialized and ready to be used (but it was not implemented yet).
A new event will be added to ClientEvents of WebDialogWindow, WebSplitter and some other controls. It will be available in hot fixes.
Thank you for report.
Hello,
Yes, this is I think expected in any ASP.NET AJAX Control client-side control. Sometimes (often) the control will not be available until the page has finished initializing. In this case, the ASP.NET Client-Side Javascript runtime provides an event called Load (akin to its server-side counter-part Page_Load) which is the safe place to use $find to get instances to client-side control.
Example:
Sys.Application.add_load(loadHandler); function loadHandlee() { var dialogWindow = $find("<%= WebDialogWindow1.ClientID %>"); ... }
More info on ASP.NET Ajax Client Side events and their lifecycle can be found here:
http://asp.net/ajax/documentation/live/overview/AJAXClientEvents.aspx
HTH,
I'm sorry Viktor but is your best recommendation that I throw up an alert or code a delay while I wait for the control to render? Really? I could create my own div and have access to it at page load but that's not why I spent the money buying your tool suite. I am asking for a better solution than that; could you please review it again?
That is correct, the Initialize event is raised after WebDialogWindow and all its subobjects are fully created. WebDialogWindow does a lot of adjustments on client which require offsetWidth/Height and before the first paint, most of child objects are not ready for public access.
However, instance of hidden dialog should be available within onload event (with some delay; down to 0ms) and some of properties can be modified. As I said, access to particular properties and objects may bring problems, and therefore that is not supported situation.
Below is example:
<body onload="setTimeout('findDialog()',0)"><form id="form1" runat="server"> <ig:WebDialogWindow ID="WebDialogWindow1" runat="server" WindowState="Hidden"></ig:WebDialogWindow>