code in a page should show report
dt.TableName = "Table";
Session["ReportData"] = dt;
dt.AcceptChanges();
int reportheight = 1200;
string script = "window.open(\"../Reports/Report.aspx?name=rptNhapThietBi\",\"Phiếu nhập\",\"width=screen.width, height=" + reportheight + "\")";
ScriptManager.RegisterStartupScript(this, GetType(), "rptNhapThietBi", script, true);
Illustration
<a href="http://imgur.com/WtkZkDS"><img src="http://i.imgur.com/WtkZkDS.png" title="source: imgur.com" /></a>
[img]http://i.imgur.com/WtkZkDS.png[/img]
Code in ReportPage
<body>
<script type="text/javascript">
function btnprint_Click() {
var dvReport = document.getElementById("DivRePort");
var frame1 = dvReport.getElementsByTagName("iframe")[0];
if (navigator.appName.indexOf("Internet Explorer") != -1) {
frame1.name = frame1.id;
window.frames[frame1.id].focus();
window.frames[frame1.id].print();
}
else {
var frameDoc = frame1.contentWindow ? frame1.contentWindow : frame1.contentDocument.document ? frame1.contentDocument.document : frame1.contentDocument;
frameDoc.print();
}
}
window.onbeforeunload = function () { myUnloadEvent(); }
function myUnloadEvent() {
alert('Calling some alert messages here');
}
</script>
<form id="form1" runat="server">
<table style="width: 100%; height: 29px;">
<tr>
<td style="width: 40px; height: 23px;">
<dx:ASPxButton ID="ASPxButton1" runat="server" Text="In" AutoPostBack="false">
</dx:ASPxButton>
</td>
</tr>
</table>
<div style="overflow: auto" id="DivRePort">
<dx:ASPxSplitter ID="ASPxSplitter2" runat="server" Height="600px">
<Panes>
<dx:SplitterPane ScrollBars="Auto">
<ContentCollection>
<dx:SplitterContentControl runat="server">
<CR:CrystalReportViewer ID="CrystalReportViewer" runat="server" AutoDataBind="True" ToolPanelView="None" ToolPanelWidth="900px" PrintMode="ActiveX" />
</dx:SplitterContentControl>
</ContentCollection>
</dx:SplitterPane>
<dx:SplitterPane Visible="False">
<ContentCollection>
<dx:SplitterContentControl runat="server"></dx:SplitterContentControl>
</ContentCollection>
</dx:SplitterPane>
</Panes>
</dx:ASPxSplitter>
</div>
</form>
</body>
string reportname = Request.QueryString["name"] + ".rpt";
if (Session["ReportData"] != null)
{
reportdocument = new ReportDocument();
string filepath = Server.MapPath(reportname);
reportdocument.Load(filepath);
reportdocument.SetDataSource(Session["ReportData"]);
DataTable dt = new DataTable();
dt = (DataTable)Session["ReportData"];
CrystalReportViewer.ReportSource = reportdocument;
CrystalReportViewer.DataBind();
}
but when you run it does not contest
<a href="http://imgur.com/s88cxag"><img src="http://i.imgur.com/s88cxag.png" title="source: imgur.com" /></a>
[img]http://i.imgur.com/s88cxag.png[/img]