Please i need help with printing (R1.aspx) page on button click on D1.aspx.The problem now is that the print dialogue box opens up and the number of ticket to be printed can be manipulated by the users.I will prefer tthe ticket to be printed without showing the print dialogue box.My code below
HTML
D1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="D1.aspx.cs" Inherits="BioPluginWebApp_D1" %>
<!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 id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<asp:Button ID="btnpopup" runat="server" BackColor="#0099FF" Font-Bold="True" ForeColor="White"
Height="39px" OnClick="btnpopup_Click" Text="Print Now" Width="135px" />
</div>
</form>
</body>
</html>
D2.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="D2.aspx.cs" Inherits="BioPluginWebApp_D2" %>
<!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 id="Head1" runat="server">
<title>Homepage</title>
<style type="text/css">
.style4 { width: 709px; }
.style5 { }
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<table align="center" border="1px" bordercolor="blue" style="width: 811px">
<tr>
<td align="center" class="style4" style="font-size: large; color: #006699; font-family: Cambria;
font-weight: bold;">
<img src="Images/head.jpg" style="width: 811px; height: 120px" /><br />
<table style="width: 100%; height: 7px; color: #000080; background-color: #000099;">
<tr>
<td style="background-color: #006699" class="style5" align="right">
<asp:LinkButton ID="LinkButton1" runat="server" ForeColor="White" PostBackUrl="Home.aspx"
OnClick="LinkButton1_Click">Home</asp:LinkButton>
|<asp:LinkButton ID="LinkButton2" runat="server" ForeColor="White" PostBackUrl="DClient.aspx"
OnClick="LinkButton2_Click">Logout</asp:LinkButton>
</td>
</tr>
</table>
<br />
<br />
<br />
<br />
<br />
<br />
You have succesfully printed out 1 meal ticket .<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<img src="Images/Leg.jpg" style="width: 811px; height: 120px" /><br />
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
R1.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="R1.aspx.cs" Inherits="BioPluginWebApp_R1" %>
<!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 id="Head1" runat="server">
<title>Meal Reciept </title>
<style type="text/css">
.style4 { width: 474px; }
.style6 { width: 302px; }
</style>
<script type="text/javascript">
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="width: 381px; height: 411px">
<table align="center" border="1px" bordercolor="blue" style="width: 30%; height: 100%;">
<tr>
<td align="center" class="style4" style="font-size: large; color: #006699; font-family: Cambria;
font-weight: bold;">
<img src="Images/16.jpg" style="width: 130px; height: 48px" /><br />
Meal Ticket<br />
<br />
<table border="2" style="width: 80%; font-size: medium;">
<tr>
<td align="left" class="style6" style="font-family: 'Agency FB'">
Names
</td>
<td>
<asp:Label ID="Label1" runat="server" Width="211px" Font-Names="Agency FB" Height="19px">ALAN SMITH</asp:Label>
</td>
</tr>
<tr>
<td align="left" class="style6">
Department
</td>
<td>
<asp:Label ID="Label2" runat="server" Width="175px" Font-Names="Agency FB">GODWIN SPIFF</asp:Label>
</td>
</tr>
<tr>
<td align="left" class="style6">
Company
</td>
<td>
<asp:Label ID="Label3" runat="server" Width="106px" Font-Names="Agency FB">ELEXA</asp:Label>
</td>
</tr>
<tr>
<td align="left" class="style6">
Emp. No
</td>
<td>
<asp:Label ID="Label4" runat="server" Width="105px" Font-Names="Agency FB">EMP234</asp:Label>
</td>
</tr>
<tr>
<td align="left" class="style6">
Ticket No
</td>
<td>
<asp:Label ID="Label5" runat="server" Font-Bold="True" Width="100px" Font-Names="Agency FB">008974</asp:Label>
</td>
</tr>
<tr>
<td align="left" class="style6">
Value
</td>
<td>
400Naira
</td>
</tr>
<tr>
<td align="left" class="style6">
Date
</td>
<td>
<asp:Label ID="Label7" runat="server" Font-Bold="True" ForeColor="#FF9900" Width="182px"
Font-Names="Agency FB">22/02/2024</asp:Label>
</td>
</tr>
</table>
<asp:Label ID="Label6" runat="server" Width="318px"></asp:Label>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Code
D1.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class BioPluginWebApp_D1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnpopup_Click(object sender, EventArgs e)
{
Response.Redirect("D2.aspx");
}
}
D2.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class BioPluginWebApp_D2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Response.Write(Session["7"]);
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW", "var Mleft = (screen.width/2)-(760/2);var Mtop = (screen.height/2)-(700/2);window.open( 'R1.aspx', null, 'height=350,width=400,status=yes,toolbar=no,scrollbars=yes,menubar=no,location=no,top=\'+Mtop+\', left=\'+Mleft+\'' );", true);
//Response.Redirect("Home.aspx");
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
}
protected void LinkButton2_Click(object sender, EventArgs e)
{
}
}
R1.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class BioPluginWebApp_R1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ScriptManager.RegisterClientScriptBlock(this.Page, typeof(string), "print", "window.print();", true);
}
}