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

Get the parent url from window codebehind

2 Answers 1036 Views
Window
This is a migrated thread and some comments may be shown as answers.
Lars Meyer
Top achievements
Rank 2
Lars Meyer asked on 19 Apr 2010, 03:32 PM
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 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Apr 2010, 07:08 AM

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.

0
Lars Meyer
Top achievements
Rank 2
answered on 20 Apr 2010, 09:40 AM
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 :-)



Tags
Window
Asked by
Lars Meyer
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Lars Meyer
Top achievements
Rank 2
Share this question
or