943,188 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 35949
  • ASP.NET RSS
Jul 6th, 2005
0

Printing using Web Control Print button.

Expand Post »
Can anyone tell me how or what's the code for the following:
1. I have two frames on my web page. (Top and Bottom)
2. Top Frame is data
3. Bottom Frame are some Controls. (Print button, Back Button, Close Button.)
4. I do not want to use Java.
5. I'm using VB.Net creating aspx pages.

Question: I would like to do an Audit of who Prints out my Page of the Top Frame. I have the audit code figured out but I would like to know if there's a way to Press the print button and Print the Page. If the page was successful printed I would update my sql database and create an audit that It was printed. I have been looking for this type of code for one week already. Please Help... Thanks
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Partydude4 is offline Offline
10 posts
since Jul 2005
Jul 6th, 2005
0

Re: Printing using Web Control Print button.

You mean, you don't want to use "JavaScript". Java and JavaScript are not related to each other and have nothing in common.

You cannot know if a user actually printed. Printing is firmly in the hands of the user - a web developer cannot write code to force a user to print.

You can, however, create a "Print" button, and USING JAVASCRIPT, invoke the "window.print()" method when they press it. Again, USING JAVASCRIPT, you can author a hidden form variable, then submit the form. Your code-behind page would read the hidden form variable to know that the user clicked your "Print" button.

I know you said you didn't want "to use Java (sic)", but there is no way to do it otherwise. Web development involves both server-side and client-side scripting. If you ignore client-side scripting, you're only doing half the job!

If you need help with the JavaScript portions, post a question in the JavaScript/DHTML forum.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Jul 6th, 2005
0

Re: Printing using Web Control Print button.

Well as you can tell I'm VERY new to this... Okay So I need to learn Java... Would you happen to know how the code might look like regarding your last statement? "You can author a hidden form variable, then submit the form. Your code-behind page would read the hidden form variable to know that the user clicked your "Print" button."
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Partydude4 is offline Offline
10 posts
since Jul 2005
Jul 6th, 2005
0

Re: Printing using Web Control Print button.

Or is there a way to print without using Java? Just by clicking the Button and using the web control button to excute the Printing. Is this possible? Do I have to use Java? I'm a VB6 Programmer and I have been able to do this in VB6. I thought that when you create a WebControl Button it will come back to the server when you press the button. Is this not true? Help... I'm going crazy..
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Partydude4 is offline Offline
10 posts
since Jul 2005
Jul 6th, 2005
0

Re: Printing using Web Control Print button.

Any ASP.NET code executes on the server. So yes, you can print something, but it will print to your web server's default printer, if there is one. I assume you want to let the user print something from their browser. You need client-side code to that.

Once more, it's "JavaScript" - Java is a completely different animal. If you ask questions about "Java", you'll get answers about "Java", which won't be relevant.

I'd be happy to help you more, but we're off-topic. You should post a new question in the JavaScript/DHTML forum.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Jul 6th, 2005
0

Re: Printing using Web Control Print button.

Regarding ASP.NET Web Server Controls. They GENERATE html code.

So, an ASP.NET Web Server Button Control, creates an <input type="button"> element.

What is different about the Web Server Button Control, is that it has server-side events, properties, and methods.

So in Visual Studio.NET, you drag a button control over onto your form. Double-click it, and a code window appears. Any code you enter there will run ON THE SERVER.

What happens is, the user browses to the page, and IIS/ASP.NET renders a page for the user. The user sees a button, and clicks it. That particular click is a client-side event, and unless you code some JavaScript, nothing in particular happens. The form does submit, however, and that's where ASP.NET does a lot of house-keeping to remember that is has a "BUTTON", and that the BUTTON was clicked, and it must run the code you authored.

But none of that helps you with your problem, because printing is a client-side affair.

Really, in your scenario, you don't NEED a WebServer Button Control. A normal html button element, will work just fine:

ASP.NET Syntax (Toggle Plain Text)
  1. <input type="button" onclick="window.print();" />

That is the basis of your solution.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Jul 6th, 2005
0

Re: Printing using Web Control Print button.

Thank you... I'll post in the correct forum... Thanks again.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Partydude4 is offline Offline
10 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: Any tutorials?
Next Thread in ASP.NET Forum Timeline: Problem with real-time app reading from serial port





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC