Get the parent url from window codebehind

3 posts, 0 answers
  1. Lars Meyer
    Lars Meyer avatar
    10 posts
    Member since:
    Jul 2005

    Posted 19 Apr 2010 Link to this post

    I need to get the url of the parent window in my radwindow codebehind.

    I tried this in the codebehind of the RadWindow:
    string test = HttpContext.Current.Request.Url.ToString(); 

    but ofcourse this gives med the url of the RadWindow itself. How do I get the url of the parent window?

    Thnx



  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Apr 2010 Link to this post

    Hello,

    You can place one HiddenField control in radwindow page and set the value from client side hen page loads. Then access the HiddenField from code behind to get the parent page url.

    ASPX in the page opened in radwindow:

     
    <asp:ScriptManager ID="ScriptManager1" runat="server">  
    </asp:ScriptManager>  
     
    <asp:HiddenField ID="HiddenField1" runat="server" /> 

    And the JavaScript for setting the HiddenField value:

     
    <script type="text/javascript">  
        function pageLoad() {  
            var oBrowserWnd = GetRadWindow().BrowserWindow;  
            var HF = document.getElementById("HiddenField1");  
            HF.value = oBrowserWnd.location.href;  
        }  
        function GetRadWindow() {  
            var oWindow = null;  
            if (window.radWindow)  
                oWindow = window.radWindow;  
            else if (window.frameElement.radWindow)  
                oWindow = window.frameElement.radWindow;  
            return oWindow;  
        }  
    </script> 

    -Shinu.

  3. Lars Meyer
    Lars Meyer avatar
    10 posts
    Member since:
    Jul 2005

    Posted 20 Apr 2010 Link to this post

    Great thanks...

    Another way I found that also works, is to pass the url to the RadWindow in the querystring. I needed to pass some other variables anyway.

    In the page that opens the RadWindow:
    <script type="text/javascript"
            function openRadWin() { 
                var url = document.location.href; 
                var oWnd = radopen("PageToOpenInWindow.aspx?parenturl=" + url, "RadWindow1"); 
                oWnd.center(); 
                oWnd.set_modal(true); 
            } 
        </script> 
    And then in the RadWindow codebehind:

    if (!string.IsNullOrEmpty(Request.QueryString["parenturl"])) 
                { 
                    string url = Request.QueryString["parenturl"]; 
                } 

    Thanks for your help :-)



Back to Top