•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 428,640 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,000 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 4297 | Replies: 1 | Solved
![]() |
•
•
Join Date: Sep 2007
Posts: 81
Reputation:
Rep Power: 2
Solved Threads: 1
Hi Fellow programmers,
I need to print the content of a repeater list located inside of an asp:panel. once the page is loaded, the code for the asp:panel is displayed as a regular div tag. What I need to do is to print the content of the div/asp:panel once the page is populated with data. As you will see from my javaScript, I have alerts set in place to see if I am getting the correct control value and it is in fact correct.
I wrote a javascript function to the job; but when I try to run the method, it tells me the value is undefined.
The Print Button
The JavaScript Code
The Panel code
I posted all the code so you could get an idea of what is going on.
I need to print the content of a repeater list located inside of an asp:panel. once the page is loaded, the code for the asp:panel is displayed as a regular div tag. What I need to do is to print the content of the div/asp:panel once the page is populated with data. As you will see from my javaScript, I have alerts set in place to see if I am getting the correct control value and it is in fact correct.
I wrote a javascript function to the job; but when I try to run the method, it tells me the value is undefined.
The Print Button
<tr id="ViewMapButtonSection" runat="server">
<td style="height: 30px;" align="center">
<asp:Button ID="btnExprot2Excel" runat="server" Text="Export To Excel" OnClientClick="createExcelSheet();" />
<asp:Button ID="btnRetrieveTracks" runat="server" Text="Retrieve Tracks" />
<asp:Button ID="btnPrint" runat="server" Text="Print Tracks" OnClientClick='javascript:PrintContent("hystoryListPanel")' /></td>
</tr>function PrintContent(ctrl)
{
//alert(ctrl);
var DocumentContainer = ctrl;
//alert(DocumentContainer);
var WindowObject = window.open('', "TrackHistoryData",
"width=420,height=225,top=250,left=345,toolbars=no,scrollbars=no,status=no,resizable=no");
//alert(ctrl);
//alert(DocumentContainer);
WindowObject.document.write(DocumentContainer.innerHTML);
//alert(ctrl);
WindowObject.document.close();
WindowObject.focus();
WindowObject.print();
WindowObject.close();
}The Panel code
<td>
<asp:Panel ID="historyListPanel" runat="server" Height="450" Width="750px" ScrollBars="Vertical" Wrap="false" Visible="true">
<asp:repeater id="historyList" runat="server">
<HeaderTemplate>
<table cellspacing="1" id="DataList" cellpadding="0" width="730px">
<tr class="listHeadSmall">
<td align="left" style="width: 75px;">TrackUID</td>
<td align="center" style="width: 75px;">Fix ID</td>
<td align="center" style="width: 100px;">Latitude</td>
<td align="center" style="width: 100px;">Longitude</td>
<td align="center" style="width: 75px;">Accuracy</td>
<td align="center" style="width: 140px;">TimeOfFix</td>
<td align="center">Case Note</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr class="listItem">
<td style="width: 75px;"><%# DataBinder.Eval(Container.DataItem, "TrackUID")%></td>
<td style="width: 75px;"><%#DataBinder.Eval(Container.DataItem, "UID")%></td>
<td style="width: 100px;"><%#DataBinder.Eval(Container.DataItem, "PositionLat")%></td>
<td align="center" style="width: 100px;"><%#DataBinder.Eval(Container.DataItem, "PositionLon")%></td>
<td align="center" style="width: 75px;"><%# DataBinder.Eval(Container.DataItem, "Accuracy") %> m.</td>
<td align="center" style="width: 140px;"><%# DataBinder.Eval(Container.DataItem, "TimeOfFix") %></td>
<td align="center" style="width: 50px;"><asp:Button ID="btnCaseNotes" runat="server" Text="Case Note"
OnClick="runCaseNote_Clicked" Enabled="false" /></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr class="listItemAlternate">
<td style="width: 75px;"><%# DataBinder.Eval(Container.DataItem, "TrackUID")%></td>
<td style="width: 75px;"><%#DataBinder.Eval(Container.DataItem, "UID")%></td>
<td style="width: 100px;"><%#DataBinder.Eval(Container.DataItem, "PositionLat")%></td>
<td align="center" style="width: 100px;"><%#DataBinder.Eval(Container.DataItem, "PositionLon")%></td>
<td align="center" style="width: 75px;"><%# DataBinder.Eval(Container.DataItem, "Accuracy") %> m.</td>
<td align="center" style="width: 140px;"><%# DataBinder.Eval(Container.DataItem, "TimeOfFix") %></td>
<td align="center" style="width: 50px;"><asp:Button ID="btnCaseNote" runat="server" Text="Case Note"
OnClick="runCaseNote_Clicked" Enabled="false" /></td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
<tr class="listFooter">
<td colspan="7">GPSIT Find & See</td>
</tr>
</table>
</FooterTemplate>
</asp:repeater>
</asp:Panel>
</td>I posted all the code so you could get an idea of what is going on.
•
•
Join Date: Sep 2007
Posts: 81
Reputation:
Rep Power: 2
Solved Threads: 1
solution:
instead of passing the control name of the container, I referenced it by using the document.getElementById() method [Line 3].
instead of passing the control name of the container, I referenced it by using the document.getElementById() method [Line 3].
function PrintContent()
{
var DocumentContainer = document.getElementById('historyListPanel');
var WindowObject = window.open('', "TrackHistoryData",
"width=740,height=325,top=200,left=250,toolbars=no,scrollbars=yes,status=no,resizable=no");
WindowObject.document.writeln(DocumentContainer.innerHTML);
WindowObject.document.close();
WindowObject.focus();
WindowObject.print();
WindowObject.close();
}![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
adult ajax asp content cross-browser javascript menu with few lines of code css deleting records from ms sql table where columns have duplicate values developer development div firefox gpt guid partition table home html internet javascript javascript smooth scrolling scroll smoothly window document position javascript tab menu with rounded corners generator microsoft mobile msdn news nokia office partition playready prevent javascript menu from getting hidden under flash movies site software sql symantec tables vista web
- printing webpages (JavaScript / DHTML / AJAX)
- AJAX : Am i right with the concept? (JavaScript / DHTML / AJAX)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Add extra images
- Next Thread: adding scrollbars to window


Linear Mode