Wnd is null when calling show()

3 posts, 0 answers
  1. Jeff
    Jeff avatar
    7 posts
    Member since:
    Jul 2011

    Posted 18 Jul 2013 Link to this post

    I'm trying to show a simple modal notification on page load but I get an error when I call show() on the window. can someone tell me what I'm missing?

    TypeError: wnd is null
    wnd.show();

    Thanks

    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
     
    <telerik:RadWindow ID="Window1" runat="server" Width="360px" Height="260px">
        <ContentTemplate>
            <p>Thank you for requesting a free issue.</p>
        </ContentTemplate>
    </telerik:RadWindow>
     
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            var key = "magazine"
     
            var regex = new RegExp("[\\?&]" + key + "=([^&#]*)");
            var qs = regex.exec(window.location.href);
       
            if(qs != null) {
                if (qs[1] == "confirmed") {
                    ShowMagazineSubscriptionConfirmed();
                }
            }
     
            function ShowMagazineSubscriptionConfirmed() {
                var wnd = $find("<%=Window1.ClientID %>");
                wnd.show();
            }
        </script>
    </telerik:RadCodeBlock>
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Jul 2013 Link to this post

    Hi Jeff,

    I have tried your code but the I am always getting a null value for the variable qs. Since you want the RadWindow to be displayed on page load you can write the corresponding code in the client side pageLoad event. Please have a look into the sample code I tried with sample values which works fine as expected.

    JavaScript:
    <telerik:RadWindow ID="Window1" runat="server" Width="360px" Height="260px">
        <ContentTemplate>
            <p>
                Thank you for requesting a free issue.</p>
        </ContentTemplate>
    </telerik:RadWindow>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function pageLoad() {
                var status = new Array("not confirmed", "confirmed");
                if (status != null) {
                    if (status[1] == "confirmed") {
                        showmagazinesubscriptionconfirmed();
                    }
                }
            }
            function showmagazinesubscriptionconfirmed() {
                var radwindow = $find("<%=Window1.ClientID %>");
                radwindow.show();
            }
        </script>
    </telerik:RadCodeBlock>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jeff
    Jeff avatar
    7 posts
    Member since:
    Jul 2011

    Posted 19 Jul 2013 Link to this post

    Thanks for your help.
Back to Top