$find Radwindow returns null

3 posts, 0 answers
  1. Joseph
    Joseph avatar
    11 posts
    Member since:
    Jul 2015

    Posted 28 Mar Link to this post

    Hi,

    I have a page with a couple of RadWindows.

    The statement $find("<%=rwPrototypeSummary.ClientID%>") returns null, while similar statement for other RadWindows works fine.

    Not sure what am I missing.

    The markup is as follows:

    <telerik:RadWindowManager ID="Singleton" runat="server" Animation="None" Behaviors="Move"
            Width="900px">
            <windows>
                <telerik:RadWindow ID="rwProtoResponseMediaEdit" Behaviors="Move, Resize, Maximize" Skin="Telerik"
                    VisibleStatusbar="false" ReloadOnShow="false" OnClientClose="rwProtoResponseMediaEdit_ClientClose"
                    BorderWidth="0" Width="950px" Modal="true" runat="server" Height="530px" Title="Prototype Media"
                    NavigateUrl="~/Agency/Authoring/ProtoResponseMediaEdit.aspx">
                </telerik:RadWindow>
                <telerik:RadWindow ID="rwResource" runat="server" Title="Pick a Resource" VisibleStatusbar="false"
                    Modal="true" NavigateUrl="~/Agency/Search/ResourceSearch.aspx"
                    Width="800" Height="650">
                </telerik:RadWindow>
                <telerik:RadWindow ID="rwPatientProfileEdit" Behaviors="Move, Resize, Maximize" Skin="Telerik"
                    VisibleStatusbar="false" ReloadOnShow="false" OnClientClose="rwPatientProfileEdit_ClientClose"
                    BorderWidth="0" Width="950px" Modal="true" runat="server" Height="530px" Title="Prototype Patient"
                    NavigateUrl="~/Agency/Authoring/PatientProfileEditEdit.aspx">
                </telerik:RadWindow>
                <telerik:RadWindow ID="rwPrototypeMediaEdit" Behaviors="Move, Resize, Maximize" Skin="Telerik"
                    VisibleStatusbar="false" ReloadOnShow="false" OnClientClose="rwPrototypeMediaEdit_ClientClose"
                    BorderWidth="0" Width="950px" Modal="true" runat="server" Height="530px" Title="Prototype Media"
                    NavigateUrl="~/Agency/Authoring/PrototypeMediaEdit.aspx">
                </telerik:RadWindow>
                <telerik:RadWindow ID="rwPrototypeSummary" Behaviors="Move, Resize, Maximize" Skin="Telerik"
                    VisibleStatusbar="false" ReloadOnShow="false" OnClientClose="rwPrototypeSummary_ClientClose"
                    BorderWidth="0" Width="950px" Modal="true" runat="server" Height="530px" Title="Prototype Summary"
                    NavigateUrl="~/Agency/Authoring/PrototypeSummary.aspx">
                </telerik:RadWindow>
            </windows>
        </telerik:RadWindowManager>

     

    The Javascript is as follows:

    <telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">

            <script type="text/javascript">

         function OpenPrototypeSummary(pid) {
                    var url = '<%= ConvertRelativeUrlToAbsoluteUrl("~/Agency/Authoring/PrototypeSummary.aspx") %>';
                    url = url + "?id=" + pid;

                    console.log(url);

                    var oWnd = $find("<%=rwPrototypeSummary.ClientID%>");

                    console.log(oWnd);

                    oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Resize + Telerik.Web.UI.WindowBehaviors.Maximize);
                    //oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Resize + Telerik.Web.UI.WindowBehaviors.Maximize);
                    oWnd.show();
                    oWnd.setSize(950, 850);
                    oWnd.setUrl(url);
                    oWnd.minimize();
                    oWnd.maximize();
                    oWnd.restore();
                    oWnd.center();
                }

                function rwPrototypeSummary_ClientClose(sender, args) {

                    var arg1 = args.get_argument();

                }
            </script>

        </telerik:RadScriptBlock>

  2. Joseph
    Joseph avatar
    11 posts
    Member since:
    Jul 2015

    Posted 30 Mar Link to this post

    I found the problem.

    The javascript function OpenPrototypeSummary(pid) is called via Scriptmanager.RegisterStartupScript.

    It seems that the function executes before RadWindow rwPrototypeSummary is loaded.

    Fixed the problem by modifying OpenPrototypeSummary(pid) to the following:

    function OpenPrototypeSummary(pid) {

                    var url = '<%= ConvertRelativeUrlToAbsoluteUrl("~/Agency/Authoring/PrototypeSummary.aspx") %>';
                    url = url + "?pid=" + pid;

                    //logsafe(url);
                    setTimeout(function () {

                        var oWnd = $find("<%= rwPrototypeSummary.ClientID %>");
                        logsafe(oWnd);

                        oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Close + Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Resize + Telerik.Web.UI.WindowBehaviors.Maximize);
                        //oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Resize + Telerik.Web.UI.WindowBehaviors.Maximize);
                        oWnd.show();
                        oWnd.setSize(1024, 850);
                        oWnd.setUrl(url);
                        oWnd.minimize();
                        oWnd.maximize();
                        oWnd.restore();
                        oWnd.center();
                    }, 500);
                }

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3599 posts

    Posted 31 Mar Link to this post

    Hello Joseph,

    A safer approach would be to use the Sys.Application.Load event when you register your script, because this event is provided by the MS AJAX framework precisely so developers can access controls and use scripts safely. You can read more on the subject in the following article: http://docs.telerik.com/devtools/aspnet-ajax/controls/window/troubleshooting/executing-javascript-code-from-server. You can find a simple example that uses this event here: http://docs.telerik.com/devtools/aspnet-ajax/controls/window/troubleshooting/opening-from-the-server.

    Regards,

    Marin Bratanov
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top