Following code will explain asp.net without asking open prompt ,automatically open the pdf file inside aspx
sample Code:
=============
public class WebForm1 : System.Web.UI.Page
{
protected CrystalDecisions.Web.CrystalReportViewer CrystalReportViewer1;
protected System.Web.UI.WebControls.Button Button1;
private CrystalReport1 report = new CrystalReport1();
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
CrystalReportViewer1.ReportSource = report;
CrystalReportViewer1.Visible = true;
}
-
private void Button1_Click(object sender, System.EventArgs e)
{
MemoryStream oStream; // using System.IO
oStream = (MemoryStream)
report.ExportToStream(
CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/pdf";
Response.BinaryWrite(oStream.ToArray());
Response.End();
}
No comments:
Post a Comment