This is a migrated thread and some comments may be shown as answers.

Get NavigateURL from javascript

3 Answers 291 Views
Window
This is a migrated thread and some comments may be shown as answers.
Kurt Kluth
Top achievements
Rank 1
Kurt Kluth asked on 26 Jul 2019, 03:33 PM

I am looking to get the URL from the radWindow from javascript.  I would rather not have to set it via javascript but not doing this it won't be able to resize the radwindow as it returns an error.  I would like to get the NavigateURL from the radWindow

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript" src="/scripts/ValidateFileType.js"></script>
    <script src="/scripts/ModalWindow.js" type="text/javascript"></script>
    <script type="text/javascript">
 
    function openWinNavigateUrl() {
            var oWnd = $find("<%= rwApplication.ClientID%>");
        oWnd.setUrl("/Repository/Application/2_CompletedPDF.pdf");
        sizeRadWindow(oWnd, 50, 55);
        oWnd.show();
    }
 
    function sizeRadWindow(oWnd, width, height) {
        var browserWidth = $telerik.$(window).width();
 
        var browserHeight = $telerik.$(window).height();
        oWnd.setSize(Math.ceil(browserWidth * width / 100), Math.ceil(browserHeight * height / 100));
        oWnd.center();
 
    }
    </script>
</telerik:RadCodeBlock>

 

                    <telerik:RadLinkButton runat="server" Text="View Completed Application"
                        OnClientClicked="openWinNavigateUrl" AutoPostBack="false" ID="_appLink">
                    </telerik:RadLinkButton>
<telerik:RadWindow RenderMode="Lightweight" runat="server" ID="rwApplication" NavigateUrl="/Repository/Application/2_CompletedPDF.pdf"
    Modal="true" InitialBehaviors="Maximize" RestrictionZoneID="NavigateUrlZone" AutoSize="false" VisibleStatusbar="false" ShowContentDuringLoad="false"
    Behaviors="Close, Maximize" Title="Completed Application">
</telerik:RadWindow>

3 Answers, 1 is accepted

Sort by
0
Accepted
Vessy
Telerik team
answered on 02 Aug 2019, 11:31 AM

Hi Kurt,

You can access the URL of a RadWindow object through its get_navigateUrl() method:

var url = oWnd.get_navigateUrl();

On the other hand, the faced issue is related to the set initial behaviors of the Window (InitialBehaviors="Maximize") and the fact the size is set before the window is shown. Moving the show() call just above the call of the sizeRadWindow() function and removing the set initial behvaior of the Window (due to which the control needs more time in order to calculate its size) will allow you to resize it without reseting the url:

        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                function openWinNavigateUrl() {
                    var oWnd = $find("<%= rwApplication.ClientID%>");
                    oWnd.show();

                    sizeRadWindow(oWnd, 50, 55);
                }

                function sizeRadWindow(oWnd, width, height) {
                    var browserWidth = $telerik.$(window).width();
                    var browserHeight = $telerik.$(window).height();
                    oWnd.setSize(Math.ceil(browserWidth * width / 100), Math.ceil(browserHeight * height / 100));
                    oWnd.center();
                }
            </script>
        </telerik:RadCodeBlock>

        <telerik:RadLinkButton runat="server" Text="View Completed Application"
            OnClientClicked="openWinNavigateUrl" AutoPostBack="false" ID="_appLink">
        </telerik:RadLinkButton>
        <telerik:RadWindow RenderMode="Lightweight" runat="server" ID="rwApplication" NavigateUrl="/Repository/Application/2_CompletedPDF.pdf"
            Modal="true" RestrictionZoneID="NavigateUrlZone" AutoSize="false" VisibleStatusbar="false" ShowContentDuringLoad="false"
            Behaviors="Close, Maximize" Title="Completed Application">
        </telerik:RadWindow>

 

Regards, Vessy
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Kurt Kluth
Top achievements
Rank 1
answered on 05 Aug 2019, 01:27 PM
Thank you Vessy for providing the answer and pointing out a bigger issue and offering a suggestion on how to fix it.  
0
Vessy
Telerik team
answered on 07 Aug 2019, 12:34 PM

Hi,

You are absolutely welcome, Kurt - I am glad the given suggestion is working for you :) Let us know whenever any further question occurs.

Regards, Vessy
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Window
Asked by
Kurt Kluth
Top achievements
Rank 1
Answers by
Vessy
Telerik team
Kurt Kluth
Top achievements
Rank 1
Share this question
or