www.webdeveloper.com
Results 1 to 1 of 1

Thread: Printing the contents of a panel?

  1. #1
    Join Date
    Jul 2004
    Posts
    43

    Printing the contents of a panel?

    How do you print the contents of a panel on a webform? I'm using VB ASP.NET.

    I have several input boxes and other objects on a panel, and I only want to print those (as a type of report). How do I do this?

    Here's the code I used from Expert's Exchange:

    Code:
    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebApplication24.WebForm1"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    	<HEAD>
    		<title>WebForm1</title>
    		<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
    		<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
    		<meta name="vs_defaultClientScript" content="JavaScript">
    		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
    		<script type="text/javascript">
    
    function printIframe(taName) {
    var printScript = frames['printit'];
    printScript.document.open();
    printScript.document.write('<html><head></head><body>');
    printScript.document.write(taName.value);
    printScript.document.write('</body></html>');
    printScript.document.close();
    printScript.focus();
    printScript.print();
    }
    
    		</script>
    	</HEAD>
    	<body MS_POSITIONING="GridLayout">
    		<form>
    			
    			<textarea name="textarea1" rows="7" cols="26" wrap="virtual" style="WIDTH: 232px; HEIGHT: 112px">Stuff goes here</textarea><br>
    			<input type="button" value="Print" onclick="printIframe(textarea1)">
    		</form>
    		<iframe name="printit" id="printit" style="WIDTH:0px;HEIGHT:0px"></iframe>
    	</body>
    </HTML>
    What I want to do is to add a webform panel so that I can hide the report form (Yes, I know about Crystal Reports, but I want the user to be able to print any edits they made that haven't been saved), and so that I can have more than one field.

    Right now, it just has a text area. When I try to add a 2nd textarea (and a 2nd PrintScript.document... line), I get a page error (it doesn't say what it is).
    Last edited by MdWebtress; 10-14-2004 at 03:55 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles