Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 638
  • Last Modified:

print gridview example

I am using this code
http://archive.aspsnippets.com/demos/gridviewprint.aspx
to print a gridview. All works fine except with the page in the background it shows a popup to select the printer.I do not want to show that popup can anyone help me with it.
thanks
0
Angela4eva
Asked:
Angela4eva
  • 7
  • 7
  • 2
2 Solutions
 
thirdCommented:
this is not possible. every browser prompts for the print dialog before you do the actual printing. this is actually good. imagine if browsers don't prompt with print dialog, there will be sites that will waste your inks in your printer.
0
 
HairbrushCommented:
A user CurtisDeHaven posted a solution to this problem at the following link:

http://social.msdn.microsoft.com/Forums/en/iewebdevelopment/thread/86eaeda9-c868-4d20-95b8-3b9bc2e19cc6

It will only work for Internet Explorer.  It has been confirmed as working in IE7 and IE8, but only after the  "Enable scripting of the WebBrowser" setting is enabled, which is non-default and could be a security risk.

So this might be an option if you are page is running in an Intranet scenario and your company has standardised on IE.
0
 
Angela4evaAuthor Commented:
"this is not possible. every browser prompts for the print dialog before you do the actual printing. this is actually good. imagine if browsers don't prompt with print dialog, there will be sites that will waste your inks in your printer. "
I do not think you understood i do not want to print automatically. I want to show the print page but not the dialogue box. There is print icon on the top of the grid page to print it
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
thirdCommented:
if that is the case, then don't call window.print() automatically. check your source code. it's probably called on the window.onload event. instead, just call it on the onclick event of your print icon.
0
 
HairbrushCommented:
Asker did not reply to expert's comments (#35196540 and #35203640).  If the asker still wants a solution, I am sure we will be happy to help them achieve a solution.
0
 
HairbrushCommented:
Asker did not reply to expert's comments (#35196540 and #35203640).  If the asker still wants a solution, I am sure we will be happy to help them achieve a solution.
0
 
Angela4evaAuthor Commented:
"It will only work for Internet Explorer.  It has been confirmed as working in IE7 and IE8, but only after the  "Enable scripting of the WebBrowser" setting is enabled, which is non-default and could be a security risk."
Cannot ask every users to change their IE settings.

0
 
Angela4evaAuthor Commented:
third,
what do you mean
0
 
Angela4evaAuthor Commented:
Please delete the question
0
 
HairbrushCommented:
Hi

Can you tell us who the users of your web site are?  Are they all staff in your company, using your network?  If so, rather than have to ask every user to change their IE settings, you can use group policy to change their security settings centrally.

There is a very useful article here: http://javascript.about.com/od/events/a/print.htm that describes why JavaScript does not have the ability to print without displaying the dialog box.  It explains that an intranet is the only scenario where it might be possible (as I stated in my previous answer).

Other users say that this approach works in Firefox: http://fiddyp.co.uk/bypass-disable-print-dialog-box-in-firefox-with-javascript-print/

I have identified a company that sells a component ($1000) that enables printing without a dialog box in IE5, 6, 7, 8 and 9: http://www.meadroid.com/scriptx/samples/Licensed/advanced/release/DOCTYPE/IE7 (click "Print the page")  It also enables you to configure the printing to a much greater degree than you would usually be able to.  See http://www.meadroid.com/scriptx/index.asp for product info.


What is boils down to is that if your site is on the Internet, then what you ask is not possible - in which case you should accept the answer that first said "this is not possible".  If it is an Intranet and you use Internet Explorer, then please consider my suggestion to configure everyone's IE settings using Group Policy.  If all your users have Firefox, please try the link above.
0
 
Angela4evaAuthor Commented:
Its Intranet. But we have 100's of web sites . I do not think network will change the group policy just for my sake.
Since I work for govt , installing a component from third part is not easy.
Even if the website is on internet I think it is possible. Just because someone said so, I do not think I will agree with them.
0
 
HairbrushCommented:
You didn't answer the question about which browser is in use.  If you can tell us that, it would help narrow down research.

You say you think what you are asking is possible but you don't know how.  Have you seen a web site which has this feature?  If not, what makes you think it is possible?
0
 
Angela4evaAuthor Commented:
You didn't answer the question about which browser is in use.  If you can tell us that, it would help narrow down research.
IE8

You say you think what you are asking is possible but you don't know how.  Have you seen a web site which has this feature?  If not, what makes you think it is possible?
I think it possible because it makes sense to me. Yes, but I do not know how.

Anyways Mine web site is an intranet and I think you asking me to change my entire network group policy so your answer can work is pretty ridiculous.
0
 
HairbrushCommented:
Ok... now we're getting somewhere.  The following code will work for Internet Explorer 8. However, because it uses an embedded ActiveX control (the Internet Explorer ActiveX control) you WILL need to make the following change:

You must change this setting (or ask your network admin to set it via group policy)
You'll just have to weigh up the benefit of "silent printing" against having to pester your network admins to make the security setting change for the Intranet Zone via group policy.  By making the change only for the Intranet zone, it will only impact sites that IE detects as being on the intranet (e.g. accessed by machine name rather than DNS address) or that are explicitly added to the Intranet zone (again achievable via Group Policy)

If you still think there is a way to do what you ask without changing any security settings, then... good luck!

I hope this helps!
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input id="printbutton" type="button" value="Print" onclick="PrintMe();" />
    </div>
    </form>
</body>
</html>
<script type="text/javascript">
function PrintMe()
{
if (navigator.appName == "Microsoft Internet Explorer")
{ 
     var PrintCommand = '<object ID="PrintCommandObject" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>';
     document.body.insertAdjacentHTML('beforeEnd', PrintCommand); 
     PrintCommandObject.ExecWB(6, 2); PrintCommandObject.outerHTML = ""; 
} 
else { 
window.print();
}
}
</script>

Open in new window

0
 
Angela4evaAuthor Commented:
As I told you already I cannot get the network to change group policy just for my sake. Its not an option.
0
 
HairbrushCommented:
Ok.  So in conclusion:

There is no way to suppress display of the print dialog in Internet Explorer 8 apart from using an embedded IE ActiveX control together with an IE security settings change to allow scripting of ActiveX controls not marked as safe.

I am sorry if that is a disappointment and not the answer you were hoping for.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 7
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now