Wrox Programmer Forums
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 12th, 2005, 06:37 AM
Authorized User
 
Join Date: Apr 2005
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default Printing Web Form

Hey All,
I'm trying to print my Web Form, as is no colour, no special font, just plan and simple as you see it on the screen.
I've used a few different codes all of which were giving different compiler messages, but the one below seems the simplest and is the one I'd like to use.
Code:
Private Sub Button3_Click
    Form2.Print
End Sub
but I'm getting the following compiler error message, I've googled away and like I said before, tried different coding styles.

BC30451: Name 'Form2' is not declared

If I write Dim Form2 As New Form, before the Form2.Print
I get the error message below,

Compiler Error Message: BC30002: Type 'Form' is not defined.

any suggestions??

 
Old May 12th, 2005, 06:51 AM
Friend of Wrox
 
Join Date: Apr 2005
Posts: 186
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

Use Javascript:window.print();

Prashant


 
Old May 12th, 2005, 07:01 AM
Authorized User
 
Join Date: Apr 2005
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Okay,
so would my code look like as follows?? (I've only used JS for simple projects, but am new to it)

<code=JScript>
<asp:Button id="Button3" onclick="window.print();" runat="server" Font-Bold="True" Text="Print Quote"></asp:Button>
</code=Jscript>

 
Old May 12th, 2005, 09:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Dwizz,

Is this a Windows or Web app? In your 1st post, you state that it is a Web form, but then in your code it appears to be Windows-ish.

If it is a web app, then you can use:

Private Sub Button3_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Load
        Button3.Attributes.Add("onclick", "javascript:window.print();")
End Sub
 
Old May 12th, 2005, 11:32 PM
Friend of Wrox
 
Join Date: Apr 2005
Posts: 186
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi,

What you have written will never work. Go ahead with the code in the previous one by katsarosj

Prashant

 
Old May 13th, 2005, 05:04 AM
Authorized User
 
Join Date: Apr 2005
Posts: 73
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for all your help Prashant and J,
I got to work, the way I wanted it.

D






Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing Web Form asters VB.NET 2002/2003 Basics 0 July 17th, 2008 05:16 AM
printing from a web page badgolfer ASP.NET 1.0 and 1.1 Basics 4 January 28th, 2005 12:07 PM
Web-Based Printing toekneel Crystal Reports 2 November 14th, 2004 10:48 PM
Printing Web Pages gaghazoul VBScript 0 February 5th, 2004 02:26 PM
Batch printing for web form Grahame2003 C# 0 January 28th, 2004 05:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.