Client Site Printing using Javascript in

1) Create simple Two (.aspx) pages.

1.1) Admin.aspx

1.2) PrintPage.aspx

2) in Admin.aspx Page put one button (id=btnPrint). On Button ClickEvent Open PrintPage.aspx using Javascript.

<asp:Button ID=”btnPrint” runat=”server” Text=”Button” OnClientClick =”return OpenPrintPage();” />

write below javascript in the code.

<script language=”javascript”>

function OpenPrintPage()


//open the printpage“PrintPage.aspx”);



3) in PrintPage.aspx Page put the two label.

<asp:Label ID=”lblUserName” runat=”server” Text=”UserName”></asp:Label>

<asp:Label ID=”lblsetUserName” runat=”server”></asp:Label>

//page load event

protected void Page_Load(object sender, EventArgs e)


//here code for data

lblsetUserName.Text = “Amit”;

//print particular page

Response.Write(“<script language=’JavaScript’ type=’text/javascript’> window.print(); </script>”);




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s