473,586 Members | 2,695 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="CallPr int('divPrint') ;" Runat=Server
/>
itmDetail.ascx. vb :

Page_load
....[snip]

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

Datalist2.DataS ource = dr
Datalist2.DataB ind()

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

Private Sub RegScript()
Dim scriptstring As String = "<script language=Javasc ript>
function CallPrint(strid ) { "
scriptstring += "var prtContent =
document.getEle mentById(strid) ;"
scriptstring += "var WinPrint =
window.open('', '','letf=0,top= 0,width=1,heigh t=1,toolbar=0,s crollbars=0,sta tus=0');"
scriptstring +=
"WinPrint.docum ent.write(prtCo ntent.innerHTML );"
scriptstring += "WinPrint.docum ent.close();"
scriptstring += "WinPrint.focus ();"
scriptstring += "WinPrint.print ();"
scriptstring += "WinPrint.close ();"
scriptstring += "prtContent.inn erHTML=strOldOn e; }"
scriptstring += "</script>"

If (Not Page.IsStartupS criptRegistered ("Startup")) Then
Page.RegisterSt artupScript("St artup", 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 2170
I think I have it.

Added this to page_load :
Button2.Attribu tes.Add("onclic k", "javascript:Cal lPrint('divPrin t');")

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
10922
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 my datalist has an id of "Datagrid3". dgChild comes back with "Nothing" while debugging. Here is my code in the itemdatabound event for the...
3
2044
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 table should be created or not. In order to do this, I need to have full control over the conditional logic for how items get displayed within a...
1
3346
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 Me.plcTabViews.Controls.Add(LoadControl("test.ascx")). There are up to 30 possibilities which are decided by CASE statements and keeps one from loading up onto another. However, I'm...
2
2198
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" Runat="server" DataTextField="PropertyValue" DataValueField="PropertyValueId"> </asp:DropDownList> </ItemTemplate> </asp:DataList>
5
1173
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 dataprovider ? Similar things with the Repeater control is for defining a kind of section in a set of dta in a grid layout ?
0
965
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 where column1 should be declared/calculated from some other project variables?
1
3955
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 DatalistItemTemplate : ITemplate { public void InstantiateIn(Control container)
0
2932
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 that the controls are loaded/unloaded based on the SelectionChanged event for the tab strip and again in Page load because with a dynamic load...
0
1905
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 that the controls are loaded/unloaded based on the SelectionChanged event for the tab strip and again in Page load because with a dynamic load...
0
7908
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8199
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8336
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6606
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.