Local Client-side printing using server vb.net code?

Hi,

Rather than use the window.print() command which is just a form dump.  I want to use vb.net code to do this as it has all the features necessary.

I came across this useful article from developers.com.  http://www.developer.com/net/net/article.php/3102381

However, when I run this it throws an exception because there is no default printer attached to the server.  Of course I don't want to print server side - thats no good.  But print client side.  The users would print to whatever print queue on the network they have connected to their own pc.

I thought about modifying the code to force a print dialog box where the user would select their printer. Would this work?  Surely it would then print to the user's own printer and not the server side. The following code displays a dialog box where the user selects their installed printer.  I've not tried the code below in an asp.net page.  Wondering what other solutions people might have.  I'm not sure where the code below for displaying a print dialog box for allowing the user to select their printer would fit in with the code in the link above.

Any guidance, suggestions - please help.  Thanks.

Private Sub printButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)

    Try
        Dim streamToPrint As StreamReader = New StreamReader("PrintMe.Txt")
        Try
            'Assumes the default printer
            Dim pd As TextFilePrintDocument = New TextFilePrintDocument(streamToPrint)

            Dim dlg As New PrintDialog()
            dlg.Document = pd
            Dim result As DialogResult = dlg.ShowDialog()

            If (result = System.Windows.Forms.DialogResult.OK) Then
                pd.Print()
            End If

        Finally
            streamToPrint.Close()
        End Try

    Catch ex As Exception
        MessageBox.Show("An error occurred printing the file - " + ex.Message)
    End Try

End Sub
0
Alcyone
6/4/2005 5:54:57 PM
asp.net.getting-started 91979 articles. 3 followers. Follow

1 Replies
1386 Views

Similar Articles

[PageSpeed] 10

Hi,

it's normal that it doesn't work client side because ASP.NET gets executed on the server, not on the client. So the thing you can do is to use the window.print() javascript function and use another style sheet especially created for the layout of your printing page (use the media=print option).

Grz, Kris.
Read my blog. Handy Firefox plugins for web developers.


Workaround for non working Mark as answer buttons.
0
XIII
6/4/2005 7:15:09 PM
Reply:

Similar Artilces:

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

use VB.NET and C#.NET code in the same C#.NET project
All-- Here is a sample that is "off the beaten path", (at least for me). Is it possible, in an ASP.NET application, using the code-behind page building technique, to have both pages written in VB.NET and pages written C#.NET?At http://www.WebLogicArts.com/DemoList.aspx there is a sample that shows that, (contrary to popular belief), it IS possible to mix ASP.NET pages built with C#.NET with ASP.NET pages built with VB.NET in the same VS.NET 2003 project. Note that this is just a "fun" sample to see if it can be done and I do not recommend this practice as a "standard" way of develo...

When to use client side varidation and server side varidation in .net?
In .net or classic web application we can varidate user data either on client isde or server side. How to select which side varidate to be used? Thanks! Generally, I use both client and server validation. I make sure the input is in the correct format and reasonably valid on the client, then I verify the data on the server. The extent of validation also depends on the type of data that I need to validate.Here are a few references:Validating ASP.NET Server ControlsIntroduction to Validating User Input in Web FormsClient-Side Validation for ASP.NET Server ControlsSecurity Checklist...

How to get new web app to use .NET 2.0 on Win2K server using .NET 1.1 as default framework?
I have .net framework1.1 and 2.0 on our server running win2K. i have existing applications that uses asp.net 1.1, i also have a new app that use ASP.net 2.0.  how can i set my new .NET 2.0 app to point to asp.net 2.0 without messing up my existing .NET 1.1 apps? To specify the ASP .Net version fro a web application, do the followingIn IIS Manager select the web application -> Properties -> ASP.Net TabSelect  ASP.Net version you want to use for the applicationRegards,PrashantDont forget to click "Mark as Answer" on the post that helped you. But I am running Win2K...

code to get clients ip in Vb.NET
Dim host As System.Net.IPHostEntry        host = System.Net.Dns.GetHostByAddress(Request.ServerVariables.Item("REMOTE_HOST"))        Dim strComputerName As String = host.HostNameWith Thanks.,R.Chezhian.,=============================================Please Mark the helpful post(s) as Answered ...

Translate c#.net code to vb.net code
Hi I can usually do the translation myself, but this time I am a bit stumped  Let us consider to rewrite Urls (more than 16000 links) using a table. Save original url and rewritten url in a table. Now add a class file in App_Code folder. class UrlRewriteModule : IHttpModule{    public void Dispose()    {        // Nothing to dispose    }    public void Init(HttpApplication context)    {        context.BeginRequest += new EventHandler(context...

How to convert C#.Net code to VB.Net code ???...
HI, i was searching something new, then i suddenly find some tips to convert C#.Net code to VB.Net but i did not do well. i am puttint its url here plz tell me how to convert C#.Net code to VB.Net. http://www.dotnetspider.com/code/C-273-Convert-C-VB-NET.aspx Jasim...Please remember to click “Mark as Answer” on the post that helps youJasim AkhtarNew Delhi ( INDIA ) It would be better if you write the problem you having, while converting from C# to VB.NET. You cannot completely rely on online converters. ThanksMark post(s) as "Answer" that helped youElectronic ScrewWebsite||Bl...

used a c#.net to vb.net converter and am now getting a syntax error.
ok I used a cool utility at http://www.kamalpatel.net/ConvertCSharp2VB.aspx to convert some c#.net to vb.net and it spit out a bunch of code which almost works but I am getting a syntax error on this line Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) I tried it that way and also like Imports (StreamReader sr = Shadows Function)() As StreamReader(objResponse.GetResponseStream()) but either way gave the same error Compiler Error Message: BC30035: Syntax error. Source Error: Line 26: Line ...

changing the src of an iframe with server side VB.net Code
Hey folks, I'm trying to load up a .aspx page into an Iframe called 'preview'. I know you can't just specify a target with the code behind of VB.net. I found a few posts elsewhere saying to use document.write(<javascript....). I gave that a try and it does absolutely nothing at all. What i'm tryign to do is to load a page into the Iframe where I have passed it dynamic values as a query string. I tried using session variables to accomplish this...and to some extent it works...but over all it really didnt' work that well. So i'm back to where I started...still trying to figure out h...

Displaying a java popup using server side VB code and returning true or false to server side
I've just spent more than a day searching these forums for the answer to this, and have found the question asked more than once, but never actually answered. I've got a form allowing a user to alter some default values for a system. When they submit changes, a java popup needs to display asking whether they are sure they want to continue... and if they click yes than the code continues. This bit I can do easily enough by adding an attribute to a button. But the next I've not been able to do, or find any way of doing in VB instead of C: Once they've clicked &q...

get data from a html textbox and use that information in VB.NET code
Hello! Can anybody tell me how to get data from a html textbox and use that information in the coding of VB.NET. Actually I am working in SALT just like Bind Element Example, I would like that user speaks the data in and I use this data to be entered in a oracle database using VB.NET coding. Right now the data is not forwarding to the click event of aspx button from the html textbox. Can any body help me soon and early. I will be grateful. Haroon is the text box an asp:textbox or a plain old html input control? If either make sure that it is dimensioned in the codebehind if that i...

How to get windows log-in user name using vb.net code?
Hi, I built an asp.net web application on our companies HR system so that recruitors can post jobs. Is there a way to get the windows logged in user name using vb.net code? This user name is using for tracking who posted the job. Thank you.   Windows Authentication provides some options, as does forms authentication.  See if you get what you need through User.Identity.Name.  Take a look at: http://www.15seconds.com/issue/020220.htmhttp://aspnet.4guysfromrolla.com/articles/120705-1.aspx JeffPlease: Don't forget to click "Mark as Answer" on the p...

use of vb.net and c#.net
i make a small website using vb.net,  in it i make a 2 class in C#.net. that i want to use in that website, i dont know how to call that class. let your class is  - class clsMyClass    {        public void myFunction()        {            // do something        }    } now the first way - create objectclsMyClass myObj = new clsMyClass();myObj.myFunction(); // call function================...

VB.NET Codebehind Code to Update SQL Server 2005 Using SQLDataSource Control?
Hi, I am a newbie in using ASP.NET 2.0 and ADO.NET.  I wrote a hangman game and want to record statistics at the end of each game.  I will create and update records in the database for each authenticated user as well as a record for the Anonymous, unauthenticated user.  After a win or loss has occurred, I want to programmatically use the SQLDataSource control to increment the statistics counters for the appropriate record in the database (note I don't want to show anything or get user input for this function). I need a VB.NET codebehind example that will show me how I sho...

Web resources about - Local Client-side printing using server vb.net code? - asp.net.getting-started

Client-side scripting - Wikipedia, the free encyclopedia
... different and changing content depending on user input, environmental conditions (such as the time of day), or other variables. Client-side ...

Senior Search Manager - Client Side!!
... strategy insight for senior IT management - resources to understand and leverage information technology. Senior Search Manager - Client Side ...

Account Manager - Client Side - Previous Agency Experience Welcome!!
Computerworld Australia is the leading source of technology news, analysis and tools for IT decision makers, managers and professionals.

Media Sales Executive - Client Side!!
Technology news and reviews for business and home.

PPC Paid Search Manager - CLIENT SIDE
Defining Technology for Australia's IT Leaders. PPC Paid Search Manager - SEM - **CLIENT SIDE** Sydney CBD Location Client side!! SEM/PPC/Paid ...

How Basecamp Next got to be so damn fast without using much client-side UI
When we started working on Basecamp Next last year, we had much internal debate about whether we should evolve the existing code base or rewrite ...

Seven Tips for Pitching From the Client's Side of the Table
I had a chance to sit on the other side of the pitch table. Here is what I learned.

Client-side coding: How to prevent malicious use?
Applications that run on a user-controlled device cannot be perfectly protected.

The client side
... regarding the professionals you seek to assist. Even better if you possess that understanding yourself, having worked on the client side. I'm ...

Ecommerce traffic being hijacked by client side malware
According to new research 15 to 30 percent of eCommerce site visitors are infected with Client Side Injected Malware (CSIM) that causes them ...

Resources last updated: 12/22/2015 7:45:20 AM