I have a Tabcontainer from the Ajax Control Toolkit and I want to print the page. But printing alway results in empty pages, only the number of pages is displayed on it.
I tried with and without updatePanel, but it ends in same result.
Anyone an idea? thanx much
Further info: After clicking a print button, I open a popup (javascript) and open the page without masterpage in it to fit it to page. A print dialog is automatically openend after poping up(javascipt)
Write the the following code in your aspx file and call the function getPrintPri.
Pameters are Panel ID. & title (For this u need to put the portion of page that u need to print in a panel, and the pass the ID of panel as first parameter of below function)
//Generating Pop-up Print Preview page
function getPrintPri(print_area,Title)
{
//Creating new page
var pp = window.open();
//Adding HTML opening tag with <HEAD> … </HEAD> portion
pp.document.writeln('<HTML><HEAD><title>Print Preview : '+Title+'</title>')
pp.document.writeln('<LINK href=CSS/style.css type="text/css" rel="stylesheet" media="all"><base target="_self"></HEAD>')
//Adding Body Tag
pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
//Adding form Tag
pp.document.writeln('<form method="post">');
//Creating two buttons Print and Close within a table
pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right><INPUT ID="PRINT" type="button" value="Print" onclick="javascript:location.reload(true);window.print();"><INPUT ID="CLOSE" type="button" value="Close" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
//Writing print area of the calling page
var docInnerHTML = document.getElementById(print_area).innerHTML
pp.document.writeln(docInnerHTML);
//Ending Tag of </form>, </body> and </HTML>
pp.document.writeln('</form></body></HTML>');
}
Chintan
Please remember to 'Mark as Answer' if this post answered your question!
What i am trying to explain is u take an <asp:Panel> and put your content (of COntent page) that u need to print on printer inside that asp:Panel and pass the ID of the <asp:Panel> to the above JavaScript function....
Hope this would solve the problem...
Please remember to 'Mark as Answer' if this post answered your question!
Chintan
Please remember to 'Mark as Answer' if this post answered your question!
This does work for pages with a tabcontainer, but I would like to have a global print button for all pages. That does work in my code instead of the tabcontainer which still remain empty.
Here is my code:
In the masterpage I switch the session variable to print.master and open the page in a new window:
Member
25 Points
70 Posts
Printing Tabcontainer results in empty pages
Jan 18, 2008 07:37 AM|r2ls|LINK
Hello all,
I have a Tabcontainer from the Ajax Control Toolkit and I want to print the page. But printing alway results in empty pages, only the number of pages is displayed on it.
I tried with and without updatePanel, but it ends in same result.
Anyone an idea? thanx much
Further info: After clicking a print button, I open a popup (javascript) and open the page without masterpage in it to fit it to page. A print dialog is automatically openend after poping up(javascipt)
Print Tabs Tabpanel Tabcontainer
Member
210 Points
67 Posts
Re: Printing Tabcontainer results in empty pages
Jan 18, 2008 09:36 AM|cdpandya1|LINK
Write the the following code in your aspx file and call the function getPrintPri.
Pameters are Panel ID. & title (For this u need to put the portion of page that u need to print in a panel, and the pass the ID of panel as first parameter of below function)
//Generating Pop-up Print Preview page
function getPrintPri(print_area,Title)
{
//Creating new page
var pp = window.open();
//Adding HTML opening tag with <HEAD> … </HEAD> portion
pp.document.writeln('<HTML><HEAD><title>Print Preview : '+Title+'</title>')
pp.document.writeln('<LINK href=CSS/style.css type="text/css" rel="stylesheet" media="all"><base target="_self"></HEAD>')
//Adding Body Tag
pp.document.writeln('<body MS_POSITIONING="GridLayout" bottomMargin="0" leftMargin="0" topMargin="0" rightMargin="0">');
//Adding form Tag
pp.document.writeln('<form method="post">');
//Creating two buttons Print and Close within a table
pp.document.writeln('<TABLE width=100%><TR><TD></TD></TR><TR><TD align=right><INPUT ID="PRINT" type="button" value="Print" onclick="javascript:location.reload(true);window.print();"><INPUT ID="CLOSE" type="button" value="Close" onclick="window.close();"></TD></TR><TR><TD></TD></TR></TABLE>');
//Writing print area of the calling page
var docInnerHTML = document.getElementById(print_area).innerHTML
pp.document.writeln(docInnerHTML);
//Ending Tag of </form>, </body> and </HTML>
pp.document.writeln('</form></body></HTML>');
}
Please remember to 'Mark as Answer' if this post answered your question!
Member
25 Points
70 Posts
Re: Printing Tabcontainer results in empty pages
Jan 18, 2008 09:51 AM|r2ls|LINK
thanx for your replay.
My problem is, the print button is on the masterpage that does not know the panelid.
I just know the URL, open it without masterpage and want to print, which works fine as long as no tabcontainer is used
Member
210 Points
67 Posts
Re: Printing Tabcontainer results in empty pages
Jan 19, 2008 04:44 AM|cdpandya1|LINK
What i am trying to explain is u take an <asp:Panel> and put your content (of COntent page) that u need to print on printer inside that asp:Panel and pass the ID of the <asp:Panel> to the above JavaScript function....
Hope this would solve the problem...
Please remember to 'Mark as Answer' if this post answered your question!
Please remember to 'Mark as Answer' if this post answered your question!
Member
25 Points
70 Posts
Re: Printing Tabcontainer results in empty pages
Jan 21, 2008 02:44 AM|r2ls|LINK
I tried that way but I failed, but this could be due to I am relative new to .NET
Do you have some example code?
All-Star
62358 Points
6684 Posts
Re: Printing Tabcontainer results in empty pages
Jan 23, 2008 02:25 AM|Hong-Gang Chen - MSFT|LINK
Hi r2ls,
According to your requirement, I write a demo for your reference, see the following code:
AJAXTap.aspx:
Let me know if I have misunderstood what you mean. Thanks.Hope it helps,
Hong Gang
If you have any feedback about my replies,please contactmsdnmg@microsoft.com.
Microsoft One Code Framework
Member
25 Points
70 Posts
Re: Printing Tabcontainer results in empty pages
Jan 28, 2008 05:40 AM|r2ls|LINK
Here is my code:
In the masterpage I switch the session variable to print.master and open the page in a new window:
in each page I ask the session for the current masterpage
the print.master is just an empty container which opens a print dialog
that does work. But Tabcontainer are printed as white pages [*-)]