473,409 Members | 1,943 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,409 software developers and data experts.

datalist, js function, printing - is innerhtml ignoring <div class="x"> read from SQL db

Here's the scenario: I have a javascript function taking the contents
of a datalist ( content from a SQL db ) and opening it in a new window
to allow the user to print. The pop-up window successfully applies the
formatting from the datalist ( ie the dl's <ItemStyle> properties ),
but ignores any of the formatting 'hard coded' into the SQL data being
returned, eg things like <div class="newpara">. This in-table
formatting appears OK on the normal web page when the datalist is
loaded, it's just not being kept when the new window for print pops-up.

Any ideas, or workaround?

Private Sub RegPrintScript()
imgPrint.Attributes.Add("onclick",
"javascript:CallPrint('divPrint');")

Dim scriptstring As String = "<script language=Javascript>
function CallPrint(strid) { "
scriptstring += "var prtContent =
document.getElementById(strid);"
scriptstring += "var WinPrint =
window.open('','','left=100,top=150,width=600,heig ht=500,toolbar=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>"

'Page.RegisterClientScriptBlock("clientScript", scriptstring)

If (Not Page.IsClientScriptBlockRegistered("clientScript") )
Then
Page.RegisterClientScriptBlock("clientScript",
scriptstring)
End If
End Sub
The datalist is enclosed in a <DIV id="divprint"> </DIV> tag.

Nov 19 '05 #1
2 2941
I've just realised that the various <div class='x'> styling from
datalist items are being ignored too.

<ItemStyle Font-Size="10pt" Font-Names="=Arial" BorderWidth="0px"
ForeColor="#000033"
BackColor="White"></ItemStyle>
<ItemTemplate>
<div class="Title">
<%# DataBinder.Eval(Container.DataItem, "Title") %>
</div>

Is this a known issue ( css styles ignored on client side scripting ),
or is my js function incomplete?

Nov 19 '05 #2
in the spirit of goodwill here's how to read in the css page so the div
classes of the datalist are rendered to the pop-up window/for print.

scriptstring += "WinPrint.document.write('<HTML><Head><LINK
href=""printpage.css"" type=""text/css""
rel=""stylesheet""></Head><Body>'); "
scriptstring +=
"WinPrint.document.write(prtContent.innerHTML) ;"
scriptstring += "WinPrint.document.write('</Body></HTML>'); "

Bob

Nov 19 '05 #3

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

Similar topics

13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
4
by: Akbar | last post by:
All, I'm currently using an alt attribute in a div tag to store "keywords" for a function that will show or hide certain div's based on a given keyword. Is there a better (standard) place to put...
19
by: CMAR | last post by:
I have the following markup. The problem is that the browser, e.g., IE6, inserts several lines of blank space between the <div> and the following table. Is there a way to minimize that vertical...
3
by: Jim in Arizona | last post by:
Most of the asp.net learning I've done has been from books that were written during the 1.0 framework. I didn't have a copy of visual studio when I started reading them then I got a hold of VS 2005...
1
by: lwhitb1 | last post by:
I have been trying to load a javascript function from the body onload html tag, but I only want the function to load the first time the page is loaded: I have investigated but haven't found...
1
by: mark4asp | last post by:
<form runat="server"automatically adds <divtag to code contained within. Is there a way to stop that? Mixing block-level elements with inline-level elements messes up the HTML becasuse that is...
5
by: chakradhari.ashish | last post by:
Does anybody know how can I load an html page inside a <div</div> where the content gets update on the onclick even of anchor <a href=> </a>? I googled around and followed some links pointing me...
1
by: msg2ajay | last post by:
hi, i am working on <div> i have to hide some part of the table. I am not able to hide that table part can anybady tell me where is the error. <html> <head> <script...
36
by: Roedy Green | last post by:
The only browser I have encountered that supports <colgroup><col class="behold"></colgroup> to apply a CSS style to a whole column, is Microsoft Internet Explorer. I have been told it SHOULD NOT...
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...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...
0
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...
0
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...

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.