Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 477
  • Last Modified:

print dynamically in asp.net

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
mahajan344
Asked:
mahajan344
  • 3
2 Solutions
 
sherasinghCommented:
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
 
mahajan344Author Commented:
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
 
mahajan344Author Commented:
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
 
M3mph15Commented:
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
 
mahajan344Author Commented:
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now