Rendering a report directly into a RadWindow

2 posts, 1 answers
  1. T. Stanley
    T. Stanley avatar
    22 posts
    Member since:
    Sep 2007

    Posted 22 Nov 2009 Link to this post

    Hi.  I just got my license to Telerik Reporting and am excited to use it in my website in place of the SQL Reporting Services that I have used to now.

    My site generates numerous reports to be printed on the client computer.  I use a script to popup a single ReportRendering.aspx page to which I send report ID and parameters (parameters in a Session variable).  The page uses Response methods to stream the rendered report from the SQL Reporting engine.  I would like to replicate this process using Telerik Reporting.  So I created a page 'reportpage.aspx' that is empty except for the following code behind:


    public partial class reporting_reportpage : System.Web.UI.Page  
        protected void Page_Load(object sender, EventArgs e)  
            Telerik.Reporting.Report MyReport = new Telerik.Reporting.Report();  
            MyReport = (Telerik.Reporting.Report)Session["taljacreport"];  
        void ExportToPDF(Telerik.Reporting.Report reportToExport)  
            ReportProcessor reportProcessor = new ReportProcessor();  
            RenderingResult result = reportProcessor.RenderReport("PDF", reportToExport, null);  
            Response.ContentType = result.MimeType;  
            Response.Expires = -1;  
            Response.Buffer = true;  

    On a test page, I put a RadWindow, a test buton, and a javascript function to open the RadWindow:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TelerikTestForm.aspx.cs" Inherits="TelerikTestForm" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> 
    <html xmlns="">  
    <head runat="server">  
        <form id="form1" runat="server">  
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> 
            <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">  
                <script type="text/javascript">  
                    function PopUpReport() {  
                        var wnd = window.radopen("reporting/reportpage.aspx", "rdwReport");  
                        return false;  
                <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /> 
            <telerik:RadWindowManager ID="rwmReport" runat="server" > 
                        <telerik:RadWindow ID="rdwReport" runat="server" Width="850px" Height="1100px" Modal="true" VisibleStatusbar="False"   
                            Behaviors="Move,Close" Left="" NavigateUrl="" Top="" > 

    On the test page's code-behind, I put the following:

    public partial class TelerikTestForm : System.Web.UI.Page   
        protected void Page_Load(object sender, EventArgs e)  
        protected void Button1_Click(object sender, EventArgs e)  
            Report myreport = new userdirectory();  
            myreport = ReportMethods.AddReportParameters(myreport, null);  
            Session["taljacreport"] = myreport;  
    //        ClientScript.RegisterClientScriptBlock(this.GetType(), "openreport", "var'reporting/reportpage.aspx', '_blank', 'height=1100,width=850,directories=no,status=no,titlebar=no,toolbar=no,menubar=no,location=no');", true);  
    //        ClientScript.RegisterClientScriptBlock(this.GetType(), "openreport", "var wnd = window.radopen('reporting/reportpage.aspx', 'rdwReport'); return false;", true);  
            ClientScript.RegisterClientScriptBlock(this.GetType(), "openreport", "PopUpReport()", true);  

    The 'ReportMethods.AddReportParameters() method is one I wrote to append parameters bot the report class by parsing a concatenated string (none are needed for this report).

    Note that I have three lines of ScriptBlock execution for opening the rendering page in a browser popup or in the RadWindow.  The first, with the browser popup works, but neither of the last two do, either writing the radopen script directly (nothin happens) or via the script function (script object reference error on 'PopUpReport()'.  I imagine that this is just my poor understanding of scripting the RadWindow, but I am stuck.  I would really like to use the RadWindow since it is so good on all the browsers.  If anyone could shed some light on this for me, I would be grateful.  Thank you!

    Thomas Stanley

  2. Answer
    Georgi Tunev
    Georgi Tunev avatar
    7207 posts

    Posted 25 Nov 2009 Link to this post

    Hi Thomas,

    Here is one way to call the JavaScript properly:

    protected void Button1_Click(object sender, EventArgs e)
        //Report myreport = new userdirectory();
        //myreport = ReportMethods.AddReportParameters(myreport, null);
        //Session["taljacreport"] = myreport;
        //        ClientScript.RegisterClientScriptBlock(this.GetType(), "openreport", "var'reporting/reportpage.aspx', '_blank', 'height=1100,width=850,directories=no,status=no,titlebar=no,toolbar=no,menubar=no,location=no');", true); 
        //        ClientScript.RegisterClientScriptBlock(this.GetType(), "openreport", "var wnd = window.radopen('reporting/reportpage.aspx', 'rdwReport'); return false;", true); 
        string script = "function f(){PopUpReport(); Sys.Application.remove_load(f);}; Sys.Application.add_load(f);";
        ClientScript.RegisterStartupScript(this.GetType(), "openreport", script, true);

    More information on the subject is available in this blog post:

    I also noticed that you have set a very high value for the Height property - that is why I would suggest to set the KeepInScreenBounds property of the RadWindowManager to true. This will ensure that when the window is shown, its toolbar will be visible in the viewport.

    Best wishes,
    Georgi Tunev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. DevCraft R3 2016 release webinar banner
Back to Top