User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 392,064 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,252 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 16164 | Replies: 6
Reply
Join Date: Jul 2005
Posts: 10
Reputation: Partydude4 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Partydude4 Partydude4 is offline Offline
Newbie Poster

Printing using Web Control Print button.

  #1  
Jul 6th, 2005
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Printing using Web Control Print button.

  #2  
Jul 6th, 2005
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.
Reply With Quote  
Join Date: Jul 2005
Posts: 10
Reputation: Partydude4 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Partydude4 Partydude4 is offline Offline
Newbie Poster

Re: Printing using Web Control Print button.

  #3  
Jul 6th, 2005
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."
Reply With Quote  
Join Date: Jul 2005
Posts: 10
Reputation: Partydude4 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Partydude4 Partydude4 is offline Offline
Newbie Poster

Re: Printing using Web Control Print button.

  #4  
Jul 6th, 2005
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..
Reply With Quote  
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Printing using Web Control Print button.

  #5  
Jul 6th, 2005
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.
Reply With Quote  
Join Date: Dec 2004
Posts: 1,589
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: Printing using Web Control Print button.

  #6  
Jul 6th, 2005
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:

<input type="button" onclick="window.print();" />

That is the basis of your solution.
Reply With Quote  
Join Date: Jul 2005
Posts: 10
Reputation: Partydude4 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Partydude4 Partydude4 is offline Offline
Newbie Poster

Re: Printing using Web Control Print button.

  #7  
Jul 6th, 2005
Thank you... I'll post in the correct forum... Thanks again.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb ASP.NET Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 11:50 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC