<head>
<script type="text/javascript">
function PrintPanel() {
var panel = document.getElementById("<%=pnlContents.ClientID
%>");
// var printWindow = window.open('',
'', 'height=1000,width=1000');
var printWindow = window.open('', '', 'height=1,width=1');
printWindow.document.write('<html><head><title>OPD
Form</title>');
printWindow.document.write('</head><body
>');
printWindow.document.write(panel.innerHTML);
printWindow.document.write('</body></html>');
printWindow.document.close();
printWindow.focus();
printWindow.print();
printWindow.close();
setTimeout(function () {
printWindow.print();
}, 500);
return false;
}
</script>
</head>
<body>
<asp:Button ID="ButtonSubmitTop"
runat="server"
class="btnSubmit"
Text="Submit"
/>
<%--<asp:Button ID="btnPrint"
class="btnSubmit" runat="server" Text="Print"
OnClientClick="return PrintPanel();"
CausesValidation="false"
/>--%>
<asp:Button ID="btnPrint"
class="btnSubmit"
runat="server"
Text="Print"
CausesValidation="false"
onclick="btnPrint_Click"
/>
<asp:Panel ID="pnlContents"
runat="server">
<table class="tblGrid"
width="800px">
<table class="tblGrid"
width="800px">
<tr>
<td class="formtdHeading"
valign="top">
Description
</td>
<td colspan="3">
<asp:TextBox ID="txtDescription"
runat="server"
Width="680px"
Height="100px"
TextMode="MultiLine"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ErrorMessage="*"
ControlToValidate="txtDescription"
Display="Dynamic"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<asp:UpdatePanel ID="UpdatePanel1"
runat="server">
<ContentTemplate>
<asp:GridView ID="gridview1" runat="server" AutoGenerateColumns="False"
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
</asp:Panel>
</body>
Code Behind File On button Control:
protected void
btnPrint_Click(object sender, EventArgs e)
{
Gridview1.Enabled
= true;
cmbAStatus.Enabled = true;
txtDesc.Enabled = true;
System.Text.StringBuilder sb = new
System.Text.StringBuilder();
sb.Append(@"<script
language='javascript'>");
sb.Append(@"PrintPanel();");
sb.Append(@"</script>");
System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(),
"PrintPanels", sb.ToString(), false);
ScriptManager.RegisterStartupScript(this, typeof(string), "OPEN_WINDOW",
@"window.frameElement.commitPopup();",
true);
}
No comments:
Post a Comment