Click here to Skip to main content
15,847,653 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi sir

I need to print text box value and barcode in I am using the below code.the barcode display correct but text box value is clear.

What I have tried:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">

<script language="javascript" type="text/javascript">

if (window.print) {
document.write('<form><input type=button name=print value="Print" ></form>');

function printDiv(divID) {
//Get the HTML of div
var divElements = document.getElementById(divID).innerHTML;
//Get the HTML of whole page
var oldPage = document.body.innerHTML;

//Reset the page's HTML with div's HTML only
document.body.innerHTML = "<html><head> </head><body>" + divElements + "</body>";

//Print Page

//Restore orignal HTML
document.body.innerHTML = oldPage;

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

<asp:Label ID="Label1" runat="server" Text="no"><asp:TextBox ID="TextBox1" runat="server">

<asp:Label ID="Label2" runat="server" Text="bnb"> <asp:TextBox ID="TextBox2" runat="server">

<asp:Label ID="Label3" runat="server" Text="hjh"><asp:TextBox ID="TextBox3" runat="server">

<asp:Label ID="Label4" runat="server" Text="bar"><telerik:RadBarcode runat="server" ID="RadBarcode1" Type="Code11" Text="123" Font-Size="16px"
LineWidth="4" Height="32px" Style="margin-left: 75px" Width="131px" ShowChecksum="False"

<asp:Button ID="Button2" runat="server" Text="Print" OnClientClick=" javascript:printDiv('importDiv')" />
Sinisa Hajnal 10-Mar-16 2:33am    
Do you know that CSS can create your print page without DOM manipulation? Use @media print and simply hide the elements of the original page when printing.

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