Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an issue with my print page. When the user clicks the print button I have a print preview that pops up and shows how the page looks before it is printed. The logo takes up half of the page, the textboxes are not aligning right and the URL, Data, Time and Page numbers are on the print out. Is the a way to fix all of this?

This is the code for the Page to be printed:

ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WordFormA.aspx.cs" Inherits="SACSCOCLogin1._1.WebForm1" %>
 
<!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 id="Head1"   runat="server">
    <title></title>
    <style>
@media print {
.header, .hide { visibility: hidden }
}
   </style>
<style type="text/css">
        .style1
        {
            font-size: x-large;
            text-align: center;
        }
        .style2
        {
            width: 100%;
        }
        .style11
        {
            height: 23px;
        text-align: left;
    }
        .newStyle1
        {
        }
        .style49
        {
            font-size: x-large;
        }
        .style51
        {
            font-weight: bold;
            font-size: x-large;
            text-align: center;
        }
        .style52
        {
            width: 670px;
        }
        .style56
        {
            font-weight: bold;
            font-size: large;
            text-align: center;
        }
        .style59
    {
        font-size: medium;
        text-align: left;
    }
    .style62
    {
        text-align: left;
    }
    .newStyle59
    {
    }
    .style69
    {
        font-size: medium;
    }
    .newStyle60
    {
    }
    .newStyle61
    {
    }
    .style80
    {
        font-size: medium;
        text-align: left;
        width: 548px;
    }
    .style83
    {
        text-align: left;
        width: 447px;
    }
    .style84
    {
        font-size: medium;
        text-align: left;
        width: 277px;
    }
    p.MsoNormal
	{margin-top:0in;
	margin-right:0in;
	margin-bottom:10.0pt;
	margin-left:0in;
	line-height:115%;
	font-size:11.0pt;
	font-family:"Calibri","sans-serif";
	}
    .style85
    {
        width: 265px;
        height: 17px;
    }
    </style>
    <script language="javascript" type="text/javascript">
// <![CDATA[

        function Reset1_onclick() {

        }

        // 
    </script>
</head>
<body background="Images/bkg-blu.jpg" bgcolor="#3399ff">
    <form id="form1"   runat="server">
    <div class="style1">
    <asp:Panel ID="Panel1" runat="server">
        <div style="text-align: left">
            <table 
                class="style2">
            </table>                                                                                                        
        <span class="style49"></span></td>
            <td class="style80">
                 </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Total Assets</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBoxTA" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Total Liabilities</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBoxTL" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Nonexpendable/Permanently Restricted Net Assets</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBoxNPRNA" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Expendable/Temporarily Restricted Net Assets</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBoxTUNA" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Total Unrestricted Net Assets</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBoxTR" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Total Revenue</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBoxTFN" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Tuition and Fees, Net</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBoxCD" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Current Debt</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBoxLTD" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style84">
                <span class="style59">Long-term Debt</span></td>
            <td class="style80">
                <asp:TextBox ID="TextBox9" runat="server" Width="180px">0</asp:TextBox>
            </td>
        </tr>
    </table>
        <table class="style2">
            <tr>
                <td>
                    <p class="MsoNormal" style="margin-top:1.15pt;margin-right:-1.0pt;margin-bottom:
0in;margin-left:11.0pt;margin-bottom:.0001pt;line-height:normal;mso-pagination:
none;mso-layout-grid-align:none;text-autospace:none">
                        ^__b>
                        <span style="font-size:
14.0pt;font-family:"Arial","sans-serif";letter-spacing:-.05pt">S</span><span 
                            style="font-size:14.0pt;font-family:"Arial","sans-serif";letter-spacing:.1pt">i</span><span 
                            style="font-size:14.0pt;font-family:"Arial","sans-serif"">gn<span 
                            style="letter-spacing:.05pt">at</span>ur<span style="letter-spacing:.05pt">e</span>s<span 
                            style="letter-spacing:-.6pt"> </span>of<span style="letter-spacing:-.05pt"> 
                        V</span><span style="letter-spacing:.05pt">e</span>r<span 
                            style="letter-spacing:.1pt">i</span><span style="letter-spacing:.05pt">f</span><span 
                            style="letter-spacing:-.05pt">i</span><span style="letter-spacing:.05pt">cat</span><span 
                            style="letter-spacing:-.05pt">i</span>on</span><span 
                            style="font-size:14.0pt;font-family:"Arial","sans-serif""><p></p>
                        </span>
                    </p>
                </td>
            </tr>
            <tr>
                <td>
                    <p class="MsoNormal" style="text-align: left">
                        ^__b>
                        <span style="font-size: 12.0pt; font-family: "Arial","sans-serif"; letter-spacing: .05pt; text-align: left;">
                        W</span><span 
                            style="font-size:12.0pt;font-family:"Arial","sans-serif"">e<span 
                            style="letter-spacing:-.05pt"> </span><span style="letter-spacing:.05pt">ce</span>r<span 
                            style="letter-spacing:-.05pt">t</span>i<span style="letter-spacing:.1pt">f</span>y<span 
                            style="letter-spacing:-.3pt"> </span><span style="letter-spacing:-.05pt">t</span>h<span 
                            style="letter-spacing:.05pt">a</span>t <span style="letter-spacing:-.05pt">t</span>he<span 
                            style="letter-spacing:.05pt"> </span>in<span style="letter-spacing:.1pt">f</span>orm<span 
                            style="letter-spacing:.05pt">a</span><span style="letter-spacing:-.05pt">t</span>ion 
                        pro<span style="letter-spacing:-.2pt">v</span>id<span style="letter-spacing:
.05pt">e</span>d in <span style="letter-spacing:-.05pt">t</span>he<span style="letter-spacing:.05pt"> 20</span><span 
                            style="letter-spacing:-.05pt">1</span>3<span style="letter-spacing:.05pt">
                        </span>Fin<span style="letter-spacing:.05pt">a</span><span 
                            style="letter-spacing:-.15pt">n</span><span style="letter-spacing:.05pt">c</span>i<span 
                            style="letter-spacing:.05pt">a</span>l<span style="letter-spacing:-.05pt">
                        </span><span style="letter-spacing:.05pt">P</span><span 
                            style="letter-spacing:-.1pt">r</span>o<span style="letter-spacing:-.05pt">f</span>ile<span 
                            style="letter-spacing:.05pt"> a</span>nd</span>
                        <span style="font-size:12.0pt;font-family:"Arial","sans-serif";removed:relative;
removed.5pt;mso-text-raise:-.5pt">Indi<span style="letter-spacing:.05pt">ca</span><span 
                            style="letter-spacing:-.05pt">t</span>ors<span 
                            style="letter-spacing:-.05pt"> </span><span style="letter-spacing:.05pt">a</span>re<span 
                            style="letter-spacing:-.05pt"> </span><span style="letter-spacing:.05pt">c</span>orr<span 
                            style="letter-spacing:-.05pt">e</span><span style="letter-spacing:.05pt">c</span><span 
                            style="letter-spacing:-.05pt">t</span>.</span><span 
                            style="font-size:12.0pt;font-family:"Arial","sans-serif""><p></p>
                        </span>
                    </p>
                </td>
            </tr>
        </table>
        <table class="style2">
            <tr>
                <td style="text-align: left">
                    _________________________</td>
                <td style="text-align: left">
                    _________________________</td>
                <td style="text-align: left">
                    _________________________</td>
            </tr>
            <tr>
                <td style="text-align: left">
                    Chief Executive Officer</td>
                <td style="text-align: left">
                    Chief Financial Officer</td>
                <td style="text-align: left">
                    Respondent(if other than CEO or CFO)</td>
            </tr>
        </table>
    <br />
    </asp:Panel>
    <br />
    <table class="style2">
        <tr>
            <td style="text-align: center">
                <asp:Button ID="ButtonPrint" runat="server" onclick="ButtonPrint_Click" 
                    style="text-align: center" Text="Print" Width="121px" />
            </td>
        </tr>
    </table>
    <br />
    <br />
    </form>
    </body>
</html>


This is the Code Behind that Page:

C#
using System;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Configuration;
using System.Drawing.Printing;
using System.IO;
using System.Web.SessionState;

namespace SACSCOCLogin1._1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
            con.Open();
            SqlConnection con2 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
            con2.Open();
            SqlConnection con3 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
            con3.Open();

            TextBoxINST_ID.Text = Session["inst_id"].ToString();
            SqlCommand scmd = new SqlCommand("Select INST_ID, LongName, City, State from Table22 where INST_ID = '" + TextBoxINST_ID.Text + "'", con);
            SqlCommand scmd2 = new SqlCommand("Select INST_ID, TOTAL_REVE, INSTRUCTIO, RESEARCH, PUBLIC_SER, ACADEMIC_S, STUDENT_SE, INSTITUTIO, PHYSICAL_P, SCHOLARSHI, AUXILIARY_, HOSPITALS, INDEPENDEN, OTHEREXP, TOTASSETS, TOTLIABILITY, NoNEXPPERMRESASSETS, UNRNETASSETS, TOTALREV, TUITFEES, CURRDEBT, LONGTERMDEBT from Table99 where INST_ID = '" + TextBoxINST_ID.Text + "'", con2);
            SqlCommand scmd3 = new SqlCommand("Select INST_ID, accessLevel from Table33 where INST_ID = '" + TextBoxINST_ID.Text + "'", con3);
            SqlDataReader dr = scmd.ExecuteReader();
            SqlDataReader dr2 = scmd2.ExecuteReader();
            SqlDataReader dr3 = scmd3.ExecuteReader();

            if (dr.Read())
                if (dr2.Read())
                    if (dr3.Read())
                    {
                        TextBoxaccessLevel.Text = dr3["accessLevel"].ToString();
                        lblCity.Text = dr["City"].ToString();
                        lblState.Text = dr["State"].ToString();
                        lblSchool.Text = dr["LongName"].ToString();
                        TextBoxInstr.Text = dr2["INSTRUCTIO"].ToString();
                        TextBoxRes.Text = dr2["RESEARCH"].ToString();
                        TextBoxPubS.Text = dr2["PUBLIC_SER"].ToString();
                        TextBoxAcad.Text = dr2["ACADEMIC_S"].ToString();
                        TextBoxStudS.Text = dr2["STUDENT_SE"].ToString();
                        TextBoxInstiS.Text = dr2["INSTITUTIO"].ToString();
                        TextBoxOperM.Text = dr2["PHYSICAL_P"].ToString();
                        TextBoxSFEDA.Text = dr2["SCHOLARSHI"].ToString();
                        TextBoxAuxE.Text = dr2["AUXILIARY_"].ToString();
                        TextBoxHosS.Text = dr2["HOSPITALS"].ToString();
                        TextBoxIndeO.Text = dr2["INDEPENDEN"].ToString();
                        TextBoxOED.Text = dr2["OTHEREXP"].ToString();
                        TextBoxTA.Text = dr2["TOTASSETS"].ToString();
                        TextBoxTL.Text = dr2["TOTLIABILITY"].ToString();
                        TextBoxNPRNA.Text = dr2["NoNEXPPERMRESASSETS"].ToString();
                        TextBoxTUNA.Text = dr2["UNRNETASSETS"].ToString();
                        TextBoxTR.Text = dr2["TOTALREV"].ToString();
                        TextBoxTFN.Text = dr2["TUITFEES"].ToString();
                        TextBoxCD.Text = dr2["CURRDEBT"].ToString();
                        TextBoxLTD.Text = dr2["LONGTERMDEBT"].ToString();
                        TextBoxTROA.Text = dr2["TOTAL_REVE"].ToString();


                    }
            dr.Close();
            con.Close();
            dr2.Close();
            con2.Close();
            dr3.Close();
            con3.Close();
        }

        protected void ButtonPrint_Click(object sender, EventArgs e)
        {
            Session["ctrl"] = Panel1;
            ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open('Print.aspx','PrintMe','height=300px,width=300px,scrollbars=1');</script>");
        }
    }
}


This the code for the Print Preview Page:

ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Print.aspx.cs" Inherits="SACSCOCLogin1._1.Print" %>

<!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">
    <div>
    
        
    </div>
    </form>
</body>
</html>


Here is the code behind that page:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SACSCOCLogin1._1
{
    public partial class Print : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Control ctrl = (Control)Session["ctrl"];
            PrintHelper.PrintWebControl(ctrl);
        }
    }
}


When the Print Button is clicked it also refers to this page for the action.

Here is the code behind for this page:

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SACSCOCLogin1._1
{
    public partial class Print : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Control ctrl = (Control)Session["ctrl"];
            PrintHelper.PrintWebControl(ctrl);
        }
    }
}


Sorry for all the code but trying to make sure I don't miss anything. Thanks.
Posted
Updated 16-Jan-14 3:12am
v3
Comments
Marc Gabrie 16-Jan-14 6:58am    
Is it a "normal" web page or one that you have designed for printing purposes? If it was designed for printing, then maybe you can create a PDF or other kind of document to get it printed without those unwanted legends.
Computer Wiz99 16-Jan-14 7:01am    
It is a web page I made just for printing. I will make a new question and post code in about an hour.
Marc Gabrie 16-Jan-14 8:17am    
Use "Improve question" link instead of making a new one
Computer Wiz99 16-Jan-14 8:53am    
Ok, It will be up in the next 5 min.
Computer Wiz99 16-Jan-14 9:06am    
It is up now.

Unfortunately, not. You can't remove those. :)

We hope to have this feature in future updates of browser.
 
Share this answer
 
Comments
Computer Wiz99 14-Jan-14 13:37pm    
Tadit Dash, Not even with CSS?
No. You can't. Else do some reearch. As per my research while answering one question, I found that it is not possible. :)
I just deleted the project. I will start another project.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900