kdeutsch
asked on
Javascript Print Function error
What I am trying to accomplish is to print the gridview that sits in a modal popup window, I get an error though that my content is undefined. from this line. My page is derived from a master page and i don't know if that is what would cause the problem. but its like ti cannot pass the gridview to the blank page.
WinPrint.document.write(Co ntent.inne rHTML);
<asp:Content ID="Content1" ContentPlaceHolderID="Head Content" Runat="Server">
<link href="../Readiness.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript">
function printMe() {
var content = document.getElementById('p nlProblems ');
var WinPrint = window.open('', '', 'letf=0,top=0,width=1,heig ht=1,toolb ar=0,scrol lbars=0,st atus=0');
WinPrint.document.write(Co ntent.inne rHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
</script>
</asp:Content>
WinPrint.document.write(Co
<asp:Content ID="Content1" ContentPlaceHolderID="Head
<link href="../Readiness.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" language="javascript">
function printMe() {
var content = document.getElementById('p
var WinPrint = window.open('', '', 'letf=0,top=0,width=1,heig
WinPrint.document.write(Co
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
</script>
</asp:Content>
Html panel
<asp:Panel ID="pnlProblems" runat="server" CssClass="ModalWindow2" style="display:none">
<asp:LinkButton ID="lnkSee" runat="server" style="display:none"></asp:LinkButton>
<table width="100%">
<tr>
<td align="center"><asp:GridView ID="myGridProblems" runat="server" Font-Size="12pt" HeaderStyle-HorizontalAlign="Center" BorderWidth="1px"
CellPadding="6" BorderColor="#404040" Font-Names="Veranda,arial,sans-serif" AutoGenerateColumns="False"
Width="80%" RowStyle-HorizontalAlign="Center"><AlternatingRowStyle BackColor="#b0c4de" /><HeaderStyle Font-Bold="true" ForeColor="White"
BackColor="SteelBlue" />
<Columns>
<asp:BoundField DataField="strCategory" HeaderText="Category" />
<asp:BoundField DataField="strTask" HeaderText="Task" />
<asp:BoundField DataField="bitAnswer" HeaderText="Status" />
</Columns>
</asp:GridView>
</td>
</tr>
<tr>
<td align="center"><asp:LinkButton ID="lnkProbCancel" runat="server">Next Soldier</asp:LinkButton>
 <asp:LinkButton ID="lnkCurrentRecord" runat="server">Return to Soldier</asp:LinkButton>
<input type="button" onclick="printMe()" /></td>
</tr>
</table>
<asp:ModalPopupExtender ID="pnlProblems_ModalPopupExtender" runat="server" Enabled="True" TargetControlID="lnkSee" PopupControlID="pnlProblems" BackgroundCssClass="modalBackground" />
</asp:Panel>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi,
Tried this but still smae error
<script type="text/javascript" language="javascript">
function printMe() {
var content = document.getElementById('< %=pnlProbl ems.Client ID%>');
var WinPrint = window.open('', '', 'letf=0,top=0,width=1,heig ht=1,toolb ar=0,scrol lbars=0,st atus=0');
WinPrint.document.write(Co ntent.inne rHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
</script>
Tried this but still smae error
<script type="text/javascript" language="javascript">
function printMe() {
var content = document.getElementById('<
var WinPrint = window.open('', '', 'letf=0,top=0,width=1,heig
WinPrint.document.write(Co
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
</script>
You also misspelled "left" in the line:
var WinPrint = window.open('', '', 'letf=0,top=0,width=1,heig ht=1,toolb ar=0,scrol lbars=0,st atus=0');
var WinPrint = window.open('', '', 'letf=0,top=0,width=1,heig
try this:
<script type="text/javascript" language="javascript">
function printMe() {
alert('<%=pnlProblems.Clie ntID%>'); // delete this line after testing
var Content = document.getElementById('< %=pnlProbl ems.Client ID%>');
var WinPrint = window.open('', '', 'left=0,top=0,width=1,heig ht=1,toolb ar=0,scrol lbars=0,st atus=0');
WinPrint.document.write(Co ntent.inne rHTML);
// WinPrint.document.close(); // are you sure about this line?
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
</script>
<script type="text/javascript" language="javascript">
function printMe() {
alert('<%=pnlProblems.Clie
var Content = document.getElementById('<
var WinPrint = window.open('', '', 'left=0,top=0,width=1,heig
WinPrint.document.write(Co
// WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();
}
</script>
ASKER
hainkurt,
you had it correct originally i just forgot to change my content from Content. Once I did this it worked fine.
you had it correct originally i just forgot to change my content from Content. Once I did this it worked fine.
good, then where is my points :)
ASKER
Thanks
var content = document.getElementById('p
-->
var content = document.getElementById('<