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 155 Views
Window
This is a migrated thread and some comments may be shown as answers.
DukeVideo
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">  
            <Windows> 
                 <telerik:radwindow runat="server" ID="radWindowReport"              
                    VisibleOnPageLoad = "false"                 
                    NavigateUrl = "Report.aspx" 
                    Title = "Import Media Codes"   
                    Height="80%" 
                    Width ="80%" 
                      
                     Behaviors="Reload,Resize,Maximize,Minimize,Close,Move,Pin"  Modal="false"   
                       
                    > 
                 </telerik:radwindow>    
            </Windows> 
        </telerik:RadWindowManager> 

(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">  
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="radFolderTreeView" EventName="NodeClick">  
                <UpdatedControls> 
                    <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="" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting>            
        </AjaxSettings>       
    </telerik:RadAjaxManager> 
    <telerik:RadAjaxLoadingPanel ID="radAjaxLoadingPanel" runat="server" Height="75px" 
        Width="75px">  
        <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' 
            style="border: 0px;" /> 
    </telerik:RadAjaxLoadingPanel> 

My code-behind is:

 
            /*
            pnlJavaScriptInjector.Controls.Clear();0
            StringBuilder sb = new StringBuilder();
            sb.Append("\n");
            sb.Append("<script type=\"text/javascript\">\n");
            sb.Append("var oWnd = $find(\"" + radWindowReport.ClientID + "\");\n");
            sb.Append("oWnd.setUrl('" + url + "');\n");
            sb.Append("oWnd.show(); \n");
            sb.Append("</script>\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
0
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;    
 



Greetings,
Svetlina
the Telerik team

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