Is it possible to send a web page (or a printable stylesheet in my case)
to the printer from code?
This is all on one .aspx page with no code behind.
I have this loop that sends each Invoice to the screen, one by one, but not printer:
<script runat="server">
while (dr.Read())
{
OrderRepeater.DataSource = GetOrders(Convert.ToInt32(dr["OrderID"]));
OrderRepeater.DataBind();
******** NEED SOME WAY TO PRINT EACH INVOICE HERE *************
}
The part that I want printed has no <html> or <body> tags:
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
.....
all the content of the printable stylesheet
.....
<script language="javascript"> <<< added
window.print();
</script>
</asp:Content>
I added the window.print() at the bottom but it only prints the last Invoice
that was on the screen from loop.
This button in the above code prints the Invoice:
<asp:Button ID="Print" runat="server" Text="Print" OnClientClick="window.print();return false;" />
I know you can't call Client scripts (like window.print()) because of security reasons.
Is there a third party or ActiveX control that will let me print to the printer from code?
Any ideas appreciated. Thanks
to the printer from code?
This is all on one .aspx page with no code behind.
I have this loop that sends each Invoice to the screen, one by one, but not printer:
<script runat="server">
while (dr.Read())
{
OrderRepeater.DataSource = GetOrders(Convert.ToInt32(dr["OrderID"]));
OrderRepeater.DataBind();
******** NEED SOME WAY TO PRINT EACH INVOICE HERE *************
}
The part that I want printed has no <html> or <body> tags:
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="Server">
.....
all the content of the printable stylesheet
.....
<script language="javascript"> <<< added
window.print();
</script>
</asp:Content>
I added the window.print() at the bottom but it only prints the last Invoice
that was on the screen from loop.
This button in the above code prints the Invoice:
<asp:Button ID="Print" runat="server" Text="Print" OnClientClick="window.print();return false;" />
I know you can't call Client scripts (like window.print()) because of security reasons.
Is there a third party or ActiveX control that will let me print to the printer from code?
Any ideas appreciated. Thanks