Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Printing A Gridview and Keeping the Gridview Visible

Posted on 2011-02-23
5
Medium Priority
?
532 Views
Last Modified: 2012-06-21
Hello-  I'm simply trying to print a GridView that is in my ASP.NET Page.  I am using the function below which works well in this environment.  After I click print or cancel the grid on the page disappears.  My question is how can I print and once the print window closes be right back on the same page with the grid and the buttons?  Do I have to reload the grid?  I am new to the .net environment.  Thanks.

function CallPrint( strid )
{
var prtContent = document.getElementById( strid );
// var strOldOne=prtContent.innerHTML;
var WinPrint = window.open('', '', 'left=0,top=0,width=1000,height=1000,status=0');
WinPrint.document.write( prtContent.innerHTML );
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.print();
WinPrint.close();
// prtContent.innerHTML=strOldOne;
}

0
Comment
Question by:thamilto0410
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 34

Expert Comment

by:it_saige
ID: 34962920
Most likely you are using a button control that has [runat=server] embedded in the markup.  If this is true, then you are doing a postback to the server.  The gridview disappearing is the result of that post back.

Either you will need to reload the grid or use a client-side version of your script without issuing a postback.

-saige-
0
 
LVL 1

Author Comment

by:thamilto0410
ID: 34962949
it_saige:  So if I use an html button and add the javascript function to it this will resolve my problem?
0
 
LVL 34

Accepted Solution

by:
it_saige earned 2000 total points
ID: 34963090
You could remove runat=server from the asp.net element.  So long as you do not need to do a postback this is perfectly valid.

-saige-
0
 
LVL 1

Author Comment

by:thamilto0410
ID: 34963272
New to all this so learning.  I did as you said and it worked perfect.  Thanks.
0
 
LVL 1

Author Closing Comment

by:thamilto0410
ID: 34963281
Thanks for the assistance.  Sometimes it can be something simple but if your new to the technology you need a push in the right direction.  That is exactly what I got.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question