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

URL generation is dynamic, server-side, so how to open a window from code behind?

1 Answer 182 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
DukeVideo asked on 18 Sep 2008, 02:00 PM

As the title says, I need to open a RadWindow with a customised URL, which is generated server-side. How is this possible?

On the old RadWindow (pre-Promoetheous) I would create a Panel and inject JavaScript in it to call the Open() method client-side, but this doesn't seem to work anymore.

At the moment, I have:

<asp:Panel ID="pnlJavascriptInjector" runat="server" /> 
        <telerik:RadWindowManager ID="radWindowManager" runat="server" Skin="Vista">  
                 <telerik:radwindow runat="server" ID="radWindowReport"              
                    VisibleOnPageLoad = "false"                 
                    NavigateUrl = "Report.aspx" 
                    Title = "Import Media Codes"   
                    Width ="80%" 
                     Behaviors="Reload,Resize,Maximize,Minimize,Close,Move,Pin"  Modal="false"   

(notice my attemp to have JavaScript injection going on).

Note that this is within an AJAX environment. I do have an AjaxManager:

    <telerik:RadAjaxManager ID="radAjaxManager" runat="server">  
            <telerik:AjaxSetting AjaxControlID="radFolderTreeView" EventName="NodeClick">  
                    <telerik:AjaxUpdatedControl ControlID="h1ReportName" LoadingPanelID="" /> 
                    <telerik:AjaxUpdatedControl ControlID="pReportDescription" LoadingPanelID="radAjaxLoadingPanel" /> 
                    <telerik:AjaxUpdatedControl ControlID="pnlReportParameters" LoadingPanelID="" /> 
                    <telerik:AjaxUpdatedControl ControlID="pnlReportButtons" LoadingPanelID="" /> 
                    <telerik:AjaxUpdatedControl ControlID="pnlJavaScriptInjector" LoadingPanelID="" /> 
                    <telerik:AjaxUpdatedControl ControlID="radWindowManager" LoadingPanelID="" /> 
    <telerik:RadAjaxLoadingPanel ID="radAjaxLoadingPanel" runat="server" Height="75px" 
        <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' 
            style="border: 0px;" /> 

My code-behind is:

            StringBuilder sb = new StringBuilder();
            sb.Append("<script type=\"text/javascript\">\n");
            sb.Append("var oWnd = $find(\"" + radWindowReport.ClientID + "\");\n");
            sb.Append("oWnd.setUrl('" + url + "');\n");
            sb.Append("; \n");
            pnlJavaScriptInjector.Controls.Add(new LiteralControl(sb.ToString()));
            RadWindow radWindow = radWindowManager.Windows[0];  
            radWindow.NavigateUrl = url;  
            radWindow.OpenerElementID = button.ClientID; 

You'll notice I've tried all sorts of ways of doing this!

Any help appreciated.

1 Answer, 1 is accepted

Sort by
Svetlina Anati
Telerik team
answered on 18 Sep 2008, 02:18 PM
Hello DukeVideo,

You can show the RadWindow from code-behind by setting its VisibleOnPageLoad property to true in the button's handler as shown below:

RadWindow radWindow = radWindowManager.Windows[0];     
radWindow.NavigateUrl = url;     
radWindow.OpenerElementID = button.ClientID;    
radWindow.VisibleOnPageLoad = true;    

the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Asked by
Top achievements
Rank 1
Answers by
Svetlina Anati
Telerik team
Share this question