473,386 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

What print options from ascx control with datalist

Ahoy,

I have an aspx web page that loads an ascx control that's populated
with various items ( in a datalist ). Select an item and the page
reloads and the datalist now shows the details.
From here I want to put a print option in, a button that will either

immediately print the contents of the datalist or maybe pop-up
something with just the currently viewed datalist contents in it (
leaving the user to print from the browser ).

But I'm not sure how best to go about it, I've been trying out some
javascript ideas I found here ( I've no idea about js, to be honest )
but with them I get a "'CallPrint' is not a member of
'ASP.ItmDetail_ascx' " error

eg itmdetail.ascx :
<DIV id="divprint">
<asp:DataList id="Datalist2" ..>
asp:button ID="btnPrint" onClick="CallPrint('divPrint');" Runat=Server
/>
itmDetail.ascx.vb :

Page_load
....[snip]

' hide the 'All News' DataList1
Panel1.Visible = True
Panel2.Visible = False

Datalist2.DataSource = dr
Datalist2.DataBind()

dr.Close()
cn.Close()
RegScript()

Private Sub RegScript()
Dim scriptstring As String = "<script language=Javascript>
function CallPrint(strid) { "
scriptstring += "var prtContent =
document.getElementById(strid);"
scriptstring += "var WinPrint =
window.open('','','letf=0,top=0,width=1,height=1,t oolbar=0,scrollbars=0,status=0');"
scriptstring +=
"WinPrint.document.write(prtContent.innerHTML) ;"
scriptstring += "WinPrint.document.close();"
scriptstring += "WinPrint.focus();"
scriptstring += "WinPrint.print();"
scriptstring += "WinPrint.close();"
scriptstring += "prtContent.innerHTML=strOldOne; }"
scriptstring += "</script>"

If (Not Page.IsStartupScriptRegistered("Startup")) Then
Page.RegisterStartupScript("Startup", scriptstring)

End If
End Sub

Not sure whether to pursue this line, I'm doing a lot of cut/paste and
getting highy confised. Are there any other ways to get a pop-up of the
contents of the datalist?

Suggestions welcome,

Thank you,
Bob

Nov 19 '05 #1
1 2155
I think I have it.

Added this to page_load :
Button2.Attributes.Add("onclick", "javascript:CallPrint('divPrint');")

and changed the button to
<asp:Button id="Button2" runat="server" Text="Print"></asp:Button>

Have printed something now, if a little weird looking.

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: bill yeager | last post by:
I have a datagrid control within a datalist control. When I try and do a "Find" on the control, the object comes back with nothing and then my pgm crashes. I am 100% sure that my datagird inside...
3
by: Ben Becker | last post by:
I am trying to build a custom crosstab type of grid where I take some items in a data grid and based on the content of the current item compared to the previous item, determine if a new row in a...
1
by: John Cosmas | last post by:
I've got a page which loads up a different user control into a placeholder control every time a button is clicked on the parent page. I use a statement like...
2
by: Olav Tollefsen | last post by:
I have a Web Form with a DataList. Inside the ItemTemplate, I have a DropDownList control. <asp:DataList ID="ProductDataList" Runat="server"> <ItemTemplate> <asp:DropDownList ID="DropDownList1"...
5
by: serge calderara | last post by:
Dear all, Does this datalist control is somehow similar as a datasource for any other control ? I really to catch the use of it, can we assimilate that control as a kind of dataset or...
0
by: Alexandru Dimitriev | last post by:
in a template.ascx for a DataList I have <% If column1 Then%> <td align="center"><%#DataBinder.Eval(CType(Container, DataListItem).DataItem, "IntegerValue")%></td> <% End If%> My problems is...
1
by: shantanu_kush | last post by:
Hi there, I am using a DataList in a composite control. The DataList has an Custom ItemTemplate(ITemplate) which adds a Button to the DataList Item as shown in the code below : public class...
0
by: CMELLO | last post by:
I have am dynamically loading a web user control based on the click of a tab strip I load the default control for the first tab in the page load event after checking page is not postback. After...
0
by: =?Utf-8?B?Y2luZHk=?= | last post by:
I have am dynamically loading a web user control based on the click of a tab strip I load the default control for the first tab in the page load event after checking page is not postback. After...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.