Solved

print dynamically in asp.net

Posted on 2009-07-05
5
462 Views
Last Modified: 2012-05-07
hello i wanna print a page..not the full page . i just wanna print some of it...
please see the attachment...
i just wanna print
 "Name",Admission No","Roll No",Toatl Amount,relaxation,Amount received....

please give me solution in not in vb.net....
thnx in advance

pic.jpg
0
Comment
Question by:mahajan344
  • 3
5 Comments
 
LVL 1

Expert Comment

by:sherasingh
ID: 24779305
Put all the Contents u want to print in One separate DIV or different DIVs after Print Click open a Window with window.open option Render a div with Document.write on new window   and put all the innerHTml of all DIVs u want to print in new windows Div and Print  it
0
 

Author Comment

by:mahajan344
ID: 24779332
but dude i used only one div in that div there are all label textbox gridview so how can i separate all these things.....!!!!!!
0
 

Author Comment

by:mahajan344
ID: 24779373
here is the code of my aspx page... now how do i seperate i all div and  print page ??
<%@ Page Language="C#" AutoEventWireup="true" Debug="true" CodeFile="New_Admission.aspx.cs" Inherits="Default2" %>
 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@ Register src="menu.ascx" tagname="menu" tagprefix="uc1" %>

<%@ Register src="footer.ascx" tagname="footer" tagprefix="uc2" %>

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

<title>Internet Services - 2nd Edition</title>

<script language="JavaScript" type="text/javascript" src="image\ts_picker.js">

     <link rel="stylesheet" type="text/css" href="~/default_prt.css" title="default1" media="print"/>
 
 

function popWindow()

{

window.open('previous_bal.aspx','popup','width=900,height=500,menubar=no,scrollbars=yes,toolbar=no,location=no,directories=no,resizable=yes,top=50,left=50');

}

</script>

<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
 

        <link href="style2.css" rel="stylesheet" type="text/css" />
 

        <style type="text/css">

            .style1

            {

                width: 100%;

            }

            .style2

            {

                width: 111px;

            }

            .style3

            {

                width: 112px;

            }

            .style4

            {

                width: 162px;

            }

            .style5

            {

                width: 143px;

            }

            .style6

            {

                width: 144px;

            }

        </style>
 

</head>

<body>

    <form id="form1" runat="server">

    <div class="content">

  <div class="header">

    <div class="logo">

      <h1><a href="/"><span class="orange">Icon's</span></a> 

          Educational <a href="/"><span class="orange">ERP</span></a><sup>1st edition</sup></h1>

    </div>

  </div>

  

<uc1:menu ID="menu1" runat="server" />

      

      <div class="left_box">

        <table class="style1">

        <tr>z

            <td class="style24">

                <asp:Label ID="Label17" runat="server" Text="Admission No"></asp:Label>

            </td>

            <td class="style3">

                <asp:TextBox ID="txt_adm" runat="server"></asp:TextBox>

            </td>

            <td class="style7">

                <asp:Button ID="Button5" runat="server" onclick="Button5_Click" Text="Ok" 

                    Height="25px" />

            </td>

            <td>

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style7">

                <asp:Label ID="Label6" runat="server" Text="Name"></asp:Label>

            </td>

            <td>

                <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>

            </td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style30">

                <asp:Label ID="Label1" runat="server" Text="Date"></asp:Label>

                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:Label ID="Label21" 

                    runat="server"></asp:Label>

                <a href="javascript:NewCal('date','ddmmmyyyy')">

                    </img>

                    &nbsp;</a>&nbsp;

                <asp:Label ID="Label10" runat="server"></asp:Label>

            </td>

            <td class="style19">

                &nbsp;<asp:Label ID="Label3" runat="server" Text="Roll No"></asp:Label>

                &nbsp;&nbsp;&nbsp;&nbsp;

            </td>

            <td class="style16">

                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>

            </td>

            <td class="style17">

                <asp:Label ID="Label7" runat="server" Text="Class"></asp:Label>

                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

                <asp:DropDownList ID="DropDownList2" runat="server">

                </asp:DropDownList>

            </td>

            <td class="style17">

            </td>

            <td class="style18">

                </td>

            <td class="style18">

                </td>

            <td class="style18">

                </td>

            <td class="style17">

                </td>

        </tr>

        <tr>

            <td class="style24">

                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

                </td>

            <td class="style3" rowspan="2">

                <asp:CheckBoxList ID="CheckBoxList1" runat="server" 

                    RepeatColumns="3">

                </asp:CheckBoxList>

            </td>

            <td class="style7">

                <asp:Label ID="Label18" runat="server" Text="Installment"></asp:Label>

            </td>

            <td>

                <asp:TextBox ID="TextBox7" runat="server"></asp:TextBox>

            </td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style24">

                &nbsp;</td>

            <td class="style7">

                <asp:Button ID="Button4" runat="server" onclick="Button4_Click" Text="ok" />

            </td>

            <td>

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style2" colspan="2" rowspan="9">

                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 

                    CellPadding="4" Width="566px" ForeColor="#333333" GridLines="None">

                    <FooterStyle BackColor="#5D7B9D" ForeColor="White" Font-Bold="True" />

                    <RowStyle HorizontalAlign="Center" ForeColor="#333333" BackColor="#F7F6F3" />

                    <Columns>

                        <asp:TemplateField HeaderText="Receipt Account">

                            <ItemTemplate>

                                <asp:Label ID="grd_lbl" Text='<%# Eval("account_type") %>' runat="server"></asp:Label>

                            </ItemTemplate>

                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Amount">

                            <ItemTemplate>

                                <asp:TextBox ID="grd_txt" Text='<%# Eval("amount") %>' runat="server">0</asp:TextBox>

                            </ItemTemplate>

                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Relaxation" Visible="false">

                            

                            <ItemTemplate>

                                <asp:CheckBox ID="CheckBox3" OnCheckedChanged ="chk3" OnLoad ="chk31" runat="server" 

                                    AutoPostBack="True" />

                                <asp:TextBox ID="grd_rel" runat="server" Visible="False">0</asp:TextBox>

                            </ItemTemplate>

                            

                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Concession" Visible="false">

                            <ItemTemplate>

                                <asp:CheckBox ID="CheckBox1"  OnCheckedChanged ="chk1" runat="server" AutoPostBack="True" />

                                <asp:TextBox ID="grd_cons" runat="server" Visible="False">0</asp:TextBox>

                            </ItemTemplate>

                        </asp:TemplateField>

                        <asp:TemplateField HeaderText="Amount Received" Visible="false">

                            <ItemTemplate>

                                <asp:CheckBox ID="CheckBox2" OnCheckedChanged="chk2" runat="server" AutoPostBack="True" />

                                <asp:TextBox ID="grd_bal" runat="server" Visible="False">0</asp:TextBox>

                            </ItemTemplate>

                        </asp:TemplateField>

                    </Columns>

                    <PagerStyle BackColor="#284775" ForeColor="White" 

                        HorizontalAlign="Center" />

                    <SelectedRowStyle BackColor="#E2DED6" ForeColor="#333333" Font-Bold="True" />

                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />

                    <EditRowStyle BackColor="#999999" />

                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />

                </asp:GridView>

            </td>

            <td class="style7" colspan="7">

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style7" colspan="2">

                <asp:Panel ID="Panel1" runat="server" Visible="False">

                    <table class="style1">

                        <tr>

                            <td class="style4">

                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

                                <asp:Label ID="Label22" runat="server" Text="Previous Balance    "></asp:Label>

                            </td>

                            <td>

                                &nbsp;&nbsp;

                                <asp:TextBox ID="TextBox8" runat="server">0</asp:TextBox>

                            </td>

                        </tr>

                    </table>

                </asp:Panel>

            </td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style7">

                <asp:Label ID="Label13" runat="server" Text="Relaxation"></asp:Label>

            </td>

            <td>

                <asp:TextBox ID="txt_rel" runat="server">0</asp:TextBox>

            </td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style7">

                <asp:Label ID="Label14" runat="server" Text="Concession"></asp:Label>

            </td>

            <td>

                <asp:TextBox ID="txt_cons" runat="server">0</asp:TextBox>

            </td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style7">

                <asp:Label ID="Label15" runat="server" Text="Balance"></asp:Label>

            </td>

            <td>

                <asp:TextBox ID="txt_bal" runat="server"></asp:TextBox>

            </td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="s&nbsp;</td>

        </tr>

        <tr>

            

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style7" colspan="2">

                <asp:Panel ID="Panel2" runat="server" Visible="False">

                    <table class="style1">

                        <tr>

                            <td class="style6">

                                <asp:Label ID="Label23" runat="server" Text="Transpotation Charges"></asp:Label>

                            </td>

                            <td>

                                <asp:TextBox ID="TextBox9" runat="server">0</asp:TextBox>

                            </td>

                        </tr>

                        <tr>

                            <td class="style6">

                                <asp:Label ID="Label24" runat="server" Text="Route Name"></asp:Label>

                            </td>

                            <td>

                                <asp:TextBox ID="TextBox10" runat="server"></asp:TextBox>

                            </td>

                        </tr>

                    </table>

                </asp:Panel>

            </td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="s&nbsp;</td>

        </tr>

        <tr>

            

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style7">

                <asp:Label ID="Label11" runat="server" Text="Total Amount"></asp:Label>

            </td>

            <td>

                <asp:TextBox ID="TextBox5" runat="server"></asp:TextBox>

            </td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style7">

                <asp:Label ID="Label9" runat="server" Text=" Amount Received"></asp:Label>

            </td>

            <td>

                <asp:TextBox ID="TextBox4" runat="server"></asp:TextBox>

            </td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style24">

                <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Save" />

            </td>

            <td class="style3">

                <asp:Button ID="Button2" runat="server" Text="Clear" onclick="Button2_Click" />

            </td>

            <td class="style7">

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style24">

                &nbsp;</td>

            <td class="style3">

                &nbsp;</td>

            <td class="style7">

                <asp:Label ID="Label12" runat="server"></asp:Label>

            </td>

            <td>

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style24">

                &nbsp;</td>

            <td class="style3">

                &nbsp;</td>

            <td class="style7">

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style24">

                &nbsp;</td>

            <td class="style3">

                &nbsp;</td>

            <td class="style7">

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style24">

                &nbsp;</td>

            <td class="style3">

                &nbsp;</td>

            <td class="style7">

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style24">

                &nbsp;</td>

            <td class="style3">

                &nbsp;</td>

            <td class="style7">

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style24">

                &nbsp;</td>

            <td class="style3">

                &nbsp;</td>

            <td class="style7">

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style24">

                &nbsp;</td>

            <td class="style3">

                &nbsp;</td>

            <td class="style7">

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style24">

                &nbsp;</td>

            <td class="style3">

                &nbsp;</td>

            <td class="style7">

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style24">

                &nbsp;</td>

            <td class="style3">

                &nbsp;</td>

            <td class="style7">

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

        <tr>

            <td class="style24">

                &nbsp;</td>

            <td class="style3">

                &nbsp;</td>

            <td class="style7">

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td>

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td class="style5">

                &nbsp;</td>

            <td>

                &nbsp;</td>

        </tr>

    </table>

            </div>

  

  <div>

 <uc2:footer ID="footer1" runat="server" />

      &nbsp;</div>

</div>

    </form>

</body>

</html>

Open in new window

0
 
LVL 6

Assisted Solution

by:M3mph15
M3mph15 earned 20 total points
ID: 24782361
HI,

Add the below code in the <head> section of your page:

     <style type="text/css" media="print">
        .ScreenOnly {display: none; visibility:hidden;}        
        .PrintOnly {display: block;}        
    </style>
    <style type="text/css" media="screen">
        .PrintOnly {display: none; visibility:hidden;}        
        .ScreenOnly {display: block;}        
    </style>

And then set the cssclass of the controls you wish to hide on print as ScreenOnly. (E.g. CssClass="ScreenOnly" )

Hope this Helps
-M3mph15

0
 

Accepted Solution

by:
mahajan344 earned 0 total points
ID: 24812280
this thing didn't work.. but i got the solution anyway thnx.
i just added css link.. "using media=print
then in that i put all that control which i  wanna hide...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Iterate a dictionnary to change values 4 53
Parse the OuterHTML Data in the txtfile using c# 4 49
Syntax error 9 45
Error when loading the database 16 58
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now