0

Is there anyone how to write the print function so that i can print out the web form with the web control contents.Here is the scenario , the web form i would like to print out have:

1.TextboxA.txt = "Sample1"
2.TextboxB.txt = "Sample2"
3.DropdownlistA.selectedIndex = "1"
4.CalendarA.


Please teach me how to write the print function in ASP.NET so that i can print out the web form with the result like this:

Name : Sample1
Age : Sample2
Sex : ValueB *(since the dropdownlist selected index is 1)
Date : CalendarA.

I had do some searching on the internet , most of them introduced the Javascript method to write the Print function.I tried , but it cannot print out the property of the web control.Please give me some help.

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by pinkygirl
0

>but it cannot print out the property of the web control.Please give me some help.

Not sure about your question but what I understood that you want to print markup (tags) of web-page. You need to encode the html markup.

<!DOCTYPE html>

&lt;html&gt;
&gt;head&gt; &gt;/head&gt;
 &lt;p&gt;Hello World&lt;p&gt;
&lt;/html&gt;
<script type="text/javascript">
  print();
</script>
0

This is how i write it... Print.js

function printdiv(empno, name, recordDate,leavetype,emailnotify,duration,datedetail) {


    var employeeName = name;
    var employeeID = empno;
    var RecordDate = recordDate;
    var LeaveType = leavetype;
    var MailNotify = emailnotify;
    var LeaveDuration = duration;
    var DateDetail = datedetail;
    var headstr = "<html><head><title></title></head><body><h2>Test Print begin....<br/><br/>";
    var footstr = "<h2></body>";
    var newstr = "Testing";


    document.body.innerHTML = headstr + newstr + "Employee Name : " + employeeName + "<br/><br/>"
    + "Employee ID: " + employeeID + "<br/><br/>" + "Record Date : " + RecordDate + "<br/><br/>" + "Leave Type : " + LeaveType +
     "<br/><br/>" + "Email Notify : " + MailNotify + "<br/><br/>" + "Leave Duration : " + LeaveDuration + "<br/><br/>"
     +"Date Detail : "+DateDetail + "<br/><br/>"+footstr;
    
    window.print();
0

I have the codes written in my notebook. It doesn't include JavaScript. Is it okay if I explain using C# codes?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.