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 window.open 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"]; |
ExportToPDF(MyReport); |
} |
void ExportToPDF(Telerik.Reporting.Report reportToExport) |
{ |
ReportProcessor reportProcessor = new ReportProcessor(); |
RenderingResult result = reportProcessor.RenderReport("PDF", reportToExport, null); |
Response.Clear(); |
Response.ContentType = result.MimeType; |
Response.Cache.SetCacheability(HttpCacheability.Private); |
Response.Expires = -1; |
Response.Buffer = true; |
Response.BinaryWrite(result.DocumentBytes); |
Response.End(); |
} |
} |
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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head runat="server"> |
<title></title> |
</head> |
<body> |
<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; |
} |
</script> |
</telerik:RadCodeBlock> |
<div> |
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" /> |
</div> |
<telerik:RadWindowManager ID="rwmReport" runat="server" > |
<Windows> |
<telerik:RadWindow ID="rdwReport" runat="server" Width="850px" Height="1100px" Modal="true" VisibleStatusbar="False" |
Behaviors="Move,Close" Left="" NavigateUrl="" Top="" > |
</telerik:RadWindow> |
</Windows> |
</telerik:RadWindowManager> |
</form> |
</body> |
</html> |
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 wnd=window.open('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