Hi,
currently i am using the aspx page and codebehind as by using
css like
@page {
size: landscape !important;
}
It works fine in chrome but not in IE. how to make in IE also by default as landscape.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PrintMarketingTimeLine.aspx.cs" Inherits="ClientDirect.MarketingTimeline.PrintMarketingTimeLine" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>:: ClientDirect - Marketing Timeline ::</title>
<style>
@media print {
#imgBtnPrint {
display: none;
}
#imgbtnClose {
display: none;
}
@page {
size: landscape !important;
}
body {
-webkit-transform: rotate(0deg) !important;
-moz-transform: rotate(0deg) !important;
transform: rotate(0deg) !important;
}
@media print and (orientation: portrait) {
/* Your code for portrait orientation */
@page {
size: landscape !important;
}
}
}
body {
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
font-size: 12px;
}
table {
border-collapse: collapse;
border: 2px solid #D9D9D6;
}
th {
border: 1px solid #D9D9D6;
text-align: center;
font-size: 13px;
color: rgb(35,53,110);
text-align: center;
border-bottom: 5px solid #D9D9D6 !important;
height: 28px;
}
td {
border: 1px solid #D9D9D6;
text-align: center;
padding:0 0 0 2px;
}
.subHead {
text-align: left;
color: rgb(35,53,110);
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
border-top: 3px solid #D9D9D6;
padding:5px;
}
</style>
<link href="../css/CommonStyle.css" rel="stylesheet" />
</head>
<body class="landScape">
<form id="form1" runat="server">
<div>
<div style="margin: 0 auto; text-align: center;">
<asp:ImageButton ID="imgbtnClose" runat="server" ToolTip="Close" ImageUrl="../images/btn_Close.png" OnClientClick="window.close();" Style="cursor: pointer;float: right;" />
<asp:ImageButton ID="imgBtnPrint" runat="server" ToolTip="Print" ImageUrl="../images/btn_Print.png" Style="cursor: pointer;float: right;" OnClick="imgBtnPrint_Click" />
<div id="divGridViewHolder" style="margin-top:10px;" runat="server"></div>
</div>
</div>
</form>
</body>
</html>
using ClientDirect.App_Code;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace ClientDirect.MarketingTimeline
{
public partial class PrintMarketingTimeLine : System.Web.UI.Page
{
#region ---------------Events--------------------
/// <summary>
/// page load method
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
//for Checking Session
if (Session.Keys.Count < 1)
{
Response.Redirect("~/Login.aspx");
}
if (!IsPostBack)
{
if (Session["dsMarketing"] != null)
{
GenerateGridView();
}
}
}
/// <summary>
/// print button click
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void imgBtnPrint_Click(object sender, ImageClickEventArgs e)
{
int Clientid = 0, userid = 0;
if (Session["Client_id"] != null)
{
Clientid = Convert.ToInt32(Session["Client_id"]);
}
if (Session["LogUserId"] != null)
{
userid = Convert.ToInt32(Session["LogUserId"]);
}
// addding log
App_Code.Common.AddLog(139, "Marketing Timeline Print", "", Clientid, 0, 0, 0, 0, userid);
ClientScript.RegisterStartupScript(GetType(), "printpage", "window.print();", true);
}
#endregion ------------Events--------------------
#region ---------------Functions--------------------
/// <summary>
/// generating the table stucture
/// </summary>
private void GenerateGridView()
{
DataSet dsMarketing = (DataSet)Session["dsMarketing"];
StringBuilder strMarketingGrd = new StringBuilder();
strMarketingGrd.Append("<table style='width:100%'><tr>");
strMarketingGrd.Append("<th style='width:15%'> Line of Business </th>");
strMarketingGrd.Append("<th style='width:15%'> Task Name </th>");
strMarketingGrd.Append("<th style='width:9%'> Start Date </th>");
strMarketingGrd.Append("<th style='width:9%'> End Date </th>");
strMarketingGrd.Append("<th style='width:15%'> Responsible Hays Team Member </th>");
strMarketingGrd.Append("<th style='width:15%'> Responsible Client Contact </th>");
strMarketingGrd.Append("<th style='width:14%'> Task Description </th>");
strMarketingGrd.Append("<th style='width:8%'> Status </th></tr>");
if (dsMarketing.Tables.Count > 0)
{
if (dsMarketing.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < dsMarketing.Tables[0].Rows.Count; i++)
{
strMarketingGrd.Append("<tr>");
for (int j = 0; j < dsMarketing.Tables[0].Columns.Count; j++)
{
if (dsMarketing.Tables[0].Rows[i][j].ToString().Contains("<B>"))
{
strMarketingGrd.Append("<td colspan='8' class='subHead'><B> " + dsMarketing.Tables[0].Rows[i][j].ToString() + "</B></td>");
break;
}
else
strMarketingGrd.Append("<td> " + dsMarketing.Tables[0].Rows[i][j].ToString().Replace("<nb>", "") + "</td>");
}
strMarketingGrd.Append("</tr>");
}
}
}
strMarketingGrd.Append("</table>");
divGridViewHolder.InnerHtml = strMarketingGrd.ToString();
}
#endregion ------------Functions--------------------
}
}