Showing posts with label ASP.Net Report Viewer. Show all posts
Showing posts with label ASP.Net Report Viewer. Show all posts

Wednesday, July 14, 2010

ReportViewer not getting displayed on IIS7

Symptoms:
Unable to render ReportViewer on ASP.NET Web pages while running on IIS7.
You have no problem viewing your reports when running on debug mode with your Visual Studio 2005.
You are able to view your reports on Report Manager but not able to view them on IIS7.
You encounter JavaScript error when loading your report page with ReportViewer. Image buttons such as calendar appear as red 'X'.

Cause:
When the ReportViewer control is added to Web Form (.aspx), the
Reserved.ReportViewerWebControl.axd httpHandler is added to System.Web section of the Web.Config file. In IIS7, it should be added under System.Webserver section.
IIS7 Handler Mappings does not contain Reserved.ReportViewerWebControl.axd httpHandler, and therefore unable to render the ReportViewer elements needed by the JavaSript.

Applies to:
Internet Information Services 7.o (IIS7)
Microsoft Report Viewer Redistributable 2005

Resolution:
Open Internet Information Services (IIS) Manager and select your Web application.
Under IIS area, double-click on Handler Mappings icon.
At the Action pane on your right, click on Add Managed Handler.
At the Add Managed Handler dialog, enter the following:
Request path: Reserved.ReportViewerWebControl.axd
Type: Microsoft.Reporting.WebForms.HttpHandler
Name: Reserved-ReportViewerWebControl-axd
Click OK.

Reserved-ReportViewerWebControl-axd handler is now added to your Handler Mappings list. Notice that the following line has also been added to your Web.config file under the system.webserver's handler section:



Run your report now!




Monday, January 19, 2009

Adding dynamic hyperlinks in the Report Viewer; ASP.Net Reports

Adding dynamic hyperlinks in the Report Viewer; ASP.Net Reports

Type the text to be displayed as the Hyperlink in the cell of your Table control added in the RDLC file. Right click on the Hyperlink text cell and click 'Navigation' tab.

Click Jump to URL radio button and add expression by clicking 'fx' button.

=iif(1<>0, Parameters!MyLink.Value+"?qBTchId=" & Fields!BatchID.Value, "")
Report Parameters can be sent from the code behind file as

Microsoft.Reporting.WebForms.ReportParameter RptLink1 = new Microsoft.Reporting.WebForms.ReportParameter("AssignLink", UriBuilder.BuildUrlNew(@"../Training/FrmAssignTraining.aspx"));
Microsoft.Reporting.WebForms.ReportParameter RptLink2 = new Microsoft.Reporting.WebForms.ReportParameter("UpdateLink", UriBuilder.BuildUrlNew(@"../Training/FrmTrainingUpdate.aspx"));
Microsoft.Reporting.WebForms.ReportParameter RptLink3 = new Microsoft.Reporting.WebForms.ReportParameter("PrintLink", UriBuilder.BuildUrlNew(@"../Training/FrmTrainingPrint.aspx"));

RptTraining.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { RptLink1, RptLink2, RptLink3 });

RptTraining.LocalReport.EnableHyperlinks = true;


=iif(1<>0,Fields!Status.Value, "")
******************/
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

///
/// The common class for building the URL for the report. Eg: UriBuilder.BuilUri("FrmAdvance.aspx");
///
public class UriBuilder
{
public UriBuilder()
{
//
// TODO: Add constructor logic here
//
}
///
/// This method Builds the physical Url with the page name provided
///
/// The name of the page
/// The URL string
public static string BuildUrl(string pageName)
{
Uri uri = new Uri(HttpContext.Current.Request.Url.AbsoluteUri);
Uri newUri = new Uri(uri, pageName);
return newUri.AbsoluteUri;
}

public static string BuildUrlNew(string pageName)
{
Uri uri = new Uri(HttpContext.Current.Request.Url.AbsoluteUri.Replace("/FeedBackQuality", ""));
Uri uri2 = new Uri(
Uri newUri = new Uri(uri, pageName);
return newUri.AbsoluteUri;
}
}


Report viewer; changing the cell background color dynamically

Report viewer; how to change the cell background color dynamically?

Select the cell which has to be colored, and press 'f4' key to get the 'properties' window of Visual Studio IDE. Go to 'BackgroundColor' property and click the '' under the dropdown list.

Just give a condition for your entity property.
=iif(Fields!TotalPrice.Value = "2500", "DarkGray", "")

Wednesday, December 3, 2008

Invoking "Save as PDF" method of Report Viewer

UserEntryFormEntity oEnt= new UserEntryFormEntity();
List oEntity = new List();

oEnt = GetReportData(JoinersId); // Method Which returns a List of Data
oEntity.Add(oEnt);

Microsoft.Reporting.WebForms.LocalReport localReport = new Microsoft.Reporting.WebForms.LocalReport();
localReport.ReportPath = Server.MapPath("~/DocumentTemplates/UserEntryForm.rdlc");

Microsoft.Reporting.WebForms.ReportDataSource oDataSource = new Microsoft.Reporting.WebForms.ReportDataSource("UserEntryFormEntity", oEntity);
localReport.DataSources.Add(oDataSource);
string reportType = "PDF";
string mimeType;
string encoding;
string fileNameExtension;
string deviceInfo = "" + " PDF" + " 8.5in" + " 11in" + " 0.5in" + " 1in" + " 1in" + " 0.5in" + "";
Microsoft.Reporting.WebForms.Warning[] warnings;
//Warning[] warnings;
string[] streams;
byte[] renderedBytes;
renderedBytes = localReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
//Clear the response stream and write the bytes to the outputstream
//Set content-disposition to "attachment" so that user is prompted to take an action
//on the file (open or save)
Response.Clear();
Response.ContentType = mimeType;
Response.AddHeader("content-disposition", "attachment; filename=foo." + fileNameExtension);
Response.BinaryWrite(renderedBytes);
Response.End();

Friday, October 10, 2008

Giving Background Dynamically for Cells in ASP.Net Report Control

Right Click in the cell and click Properties. Click on the Background color in the Property box and click expression in the dropdown box for selecting the background color.

=iif(Parameters!oTotal.Value = Fields!RowCount.Value ,"YellowGreen","White")

If Row Count and Total are equal, Background color would be YellowGreen, else White.

Giving Visibility True / False for a Report Control Row or Column

Right click in the field(cell) and click expression and add Expression as
=iif(Parameters!oTotal.Value = Fields!RowCount.Value ,False,True)


Right click in the cell again and click Properties
Click visibility tab and add expression as
=iif(Max(Fields!RowCount.Value)=5,Fields!ActualSales.Value+Fields!TOTALSales.Value,0)