.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

print only div tags asp.net page

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :ASP.Net

HI guys, I am trying to print certain elements of my web page ( open a print window) and send it to print. using the below code,   the problem is that with the approach i am following the page changes also with the atributes I specify on the Java Script,   Can someone help me ??


<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<script type="text/javascript" language="JavaScript">

    function printPartOfPage() {
        var coll = document.all.tags("Div");
        for (i = 0; i < coll.length; i++) {
            coll(i).style.overflow = "visible";


    <div id="printArea">   
    <div id="formcenter" >
    <br />

    <div id ="texttop" >
    <br />
    <br />
      <div id="image" style="margin-left: 507px">
          <input id="printButton" type="button" value="print" onclick ="printPartOfPage()"/>  
   <div style="bo

View Complete Post

More Related Resource Links

Reporting services in 2008 r2 how to get a report in a print button click event in my c#.net page


how to  get a report in my c#.net page button lick event also steps to call a report from asp.net to reporting services


Thanks in advance

Profile page throwing an error after adding some "ask me about" tags

After adding some "ask me about" tags my profile page is throwing an error. To be more precise the AskMeAbout WebPart ist throwing a thread aborted exception and I don't understand the reason for this error. After removing the tags the sites works again. Some tags work but after trying some other tags the profile page is broken again. Unhandled exception caught during execution of Microsoft.SharePoint.Portal.PageBase::ErrorHandler(). Exception information: Exception information: Microsoft.SharePoint.WebPartPages.WebPartException: Thread was being aborted. ---> System.Threading.ThreadAbortException: Thread was being aborted. at Microsoft.SharePoint.Portal.WebControls.AskMeAboutWebPart.RenderValues(HtmlTextWriter writer, Int32 startIndex, Int32 endIndex) at Microsoft.SharePoint.Portal.WebControls.AskMeAboutWebPart.RenderWebPart(HtmlTextWriter writer) at Microsoft.SharePoint.WebPartPages.WebPart.Render(HtmlTextWriter writer) at Microsoft.SharePoint.WebPartPages.SPChrome.RenderPartContents(HtmlTextWriter output, WebPart part) - -- End of inner exception stack trace --- at Microsoft.SharePoint.WebPartPages.SPChrome.RenderPartContents(HtmlTextWriter output, WebPart part) at Microsoft.SharePoint.WebPartPages.SPChrome.RenderWebPart(HtmlTextWriter output, WebPart part) at Microsoft.SharePoint.WebPartPages.WebPartZone.RenderZoneCell(HtmlTex

have print friendly page, want to hide columns of gridview

using vb.net/asp.net 2005I have linkbuttons calling the javascript function at the bottom of this post to print out the contents of a div and this is working ok but theissue that i have is inside the div is a gridview that displays links and another text column (among other colums) and I would like tohide the links and the text column next to it using css.Has anyone done this?btw, here is the javascript print function# function printThisDiv() # { # try{ # var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,"; # sOption+="scrollbars=yes,width=750,height=600,left=100,top=25"; # # var sWinHTML = document.getElementById('dvTheDivIWantToPrint').innerHTML; # # # var winprint=window.open("","",sOption); # winprint.document.open(); # winprint.document.write('<html><body>'); # winprint.document.write(sWinHTML); # winprint.document.write('</body></html>'); # winprint.document.close(); # winprint.focus(); # # }catch(err){ # txt="There was an error on this page.\n\n"; # txt+="Error description: " + err.description + "\n\n"; # txt+="Click OK to continue.\n\n"; # alert(txt); # } }

Print PDF from my page .aspx C# VS-2008

Hello I have a aspx page with Charts and DataGrips and I want to print all my page in a pdf just like it look in my page.

how to print Test-page on default Printer ?

hi how to print Test-page on default Printer  using C# Winform Code ? thank's in advance

pass datas from one page to another to print

i have a page default.aspx ..... i am getting user information for our college symposium through that page..... when the user click the save and print button......it should be saved to the database and the form should be printed... saving is working correctly......wat i want is when the user click the print button then the information should be opened in a pop u window and the user shoul print that popup window application form awaiting for reply.....very urgenthi developers.....i have a page default.aspx .....i am getting user information for our college symposium through that page.....when the user click the save and print button......it should be saved to the database and the form should be printed...saving is working correctly......wat i want is when the user click the print button then the information should be opened in a pop u window and the user shoul print that popup window application form after registration.awaiting for reply.....very urgent

how to print current page and all pages of listview?



I have a listview.When I click a "Print" button It should be  print only listview items (current page & all pages).

how to do this pls tell me?

many thanks in advance.

in crystal report i need to print each group in new page



i have one problem in crystal reports

i want print  group details ,for each group it should print in new page.

some thing like this




Transaction Number                Date                           Amount                           Remarks

   1111                                   10/1/2007                    300.00                                 JE999

   2222               &nb

I cant print listview items to second page




I have a listview...

Here is the code...

Dim alta As Integer = 0
Dim yana As Integer = 0
txt.Text = 0
txtsayfa.Text = 0

Static pagenum As Integer = 0

For i = 0 To LV.items.count-1


            Dim aralik As New RectangleF(yana + 20, ust + alta, W / 4 - 15, H)
            e.Graphics.DrawString((LV.Items(i).SubItems(2).Text), font, Brushes.Black, aralik, trim)

            pagenum = pagenum + 1
            txt.Text = txt.Text + 1
            yana = yana + W / 4
            alta = alta + 200

            txtsayfa.Text = txtsayfa.Text + 1

            If txt.Text = 1 Then
                yana = 0

Converting aspx page to pdf before print.


Hi Friends,

I google this one from a long time. but i cound't able to find proper solution.

can you guys provide sample code how to covert aspx page to pdf before print.

I have aspx page with print button on it. so when the customer click on print button, he must get the print in pdf format.

Thanks in Advance.


How to print everything except Master Page


I have a print button on my site, and when I click it I would like it to print everything EXCEPT the Master Page. I don't care to waste the space and ink on all of the menu and header stuff. Does anybody know how to do that? I'm running Visual Studio 2008. 

ssrs print at bottom of the page

Hi all,

Is there any way you can print a text at the bottom of a page without it actually being in a footer?.
Actually, there is table above the text box so i dont know how long the table is gonna be. The text needs to be at the bottom of the page, not just below the table.


How to print a report one page per input parameter?


I am working on a new report, and have been asked to have a report that may have multiple part numbner, and they want the report to keep the report details seperate for each part number. How do I do this?

It seems like I would recursively be calling the report. I have not done this before. Any help is appreciated!

__________________ Clifton Dunaway

How to print all or nothing on a single page


I have a rectange that has some printable elements.  I want everying in the rectangle to print on one page.  I don't want a new page ALWAYS before the rectange prints, I only want a new page if the entire rectange wont print on the current page.  Is there a way to do this?

Thanks very much

Excel Render - Print Header on Each Page


Hello Microsoft or Forum Members:


This seems like a simple Microsoft Based Reporting System 101 feature...But I can not find out how to do it (among other things that seem like it should work with Microsoft rendering to Microsoft).


How do I make the SSRS 2005 Header for the Report print on each of the pages in excel once it is rendered from SSRS?


All I want is an answer by MSFT that says "YES" it can be done and how or "No" it is not currently available.


I noticed I am not the only one with this type of simple question:

(see this unanswered post)


Print page visual



sorry for this question in this topic bit i dont know about palce ,

in silverlight i use this code for print

PrintDialog pd = new PrintDialog();
      PrintDocument docToPrint = new PrintDocument();
      docToPrint.DocumentName = "Bank Name";
      docToPrint.PrintPage += (s, args) =>
          args.PageVisual = this.ListView1;

but in wpf we dont have ???.PageVisual

how can do it in wpf


How to Print the Asp.net Page Contents or Full Page


Hi all,


How  to Print the Asp.net Page Contents or Full Page in ASp.net . I have to given the facility to user to print the Page with enterd Data .


How to Deal with the Print functionality in Asp.net

Any Article or suggestion is appericated .


Best Regards


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend