| | |
Printing using Web Control Print button.
Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Jul 2005
Posts: 10
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
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.
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.
•
•
Join Date: Jul 2005
Posts: 10
Reputation:
Solved Threads: 0
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."
•
•
Join Date: Jul 2005
Posts: 10
Reputation:
Solved Threads: 0
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..
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
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.
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.
•
•
Join Date: Dec 2004
Posts: 1,655
Reputation:
Solved Threads: 35
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:
That is the basis of your solution.
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)
<input type="button" onclick="window.print();" />
That is the basis of your solution.
![]() |
Similar Threads
- Printing using Web Control Print button VB.NET (JavaScript / DHTML / AJAX)
Other Threads in the ASP.NET Forum
- Previous Thread: Any tutorials?
- Next Thread: Problem with real-time app reading from serial port
| Thread Tools | Search this Thread |
.net 2.0 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer c# c#gridviewcolumn cac checkbox commonfunctions compatible confirmationcodegeneration content contenttype courier dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist deployment development dgv dropdownlist dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv formatdecimal forms formview gridview gudi homeedition iframe iis javascript jquery listbox menu microsoft mouse mssql multistepregistration news objects opera panelmasterpagebuttoncontrols redirect registration relationaldatabases reportemail rotatepage schoolproject security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 ssl textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visual-studio visualstudio web webapplications webarchitecture webdevelopemnt webdevelopment webprogramming webservice youareanotmemberofthedebuggerusers






