How to include asp.net datalist <div class='x'> formatting in javascript function

  • Thread starter yer darn tootin
  • Start date
Y

yer darn tootin

Bit stuck with this, javascript novice I'm afraid, any advice?


Here's the scenario: I have a javascript function taking the contents
of an asp.net datalist control ( 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 all the <div class="x"> set on each item.

Any ideas, or workaround?

Private Sub RegPrintScript()
imgPrint.Attributes.Add("oncli­ck",
"javascript:CallPrint('divPrin­t');")


Dim scriptstring As String = "<script language=Javascript>
function CallPrint(strid) { "
scriptstring += "var prtContent =
document.getElementById(strid)­;"
scriptstring += "var WinPrint =
window.open('','','left=100,to­p=150,width=600,height=500,too­lbar=0,scrollbars=0,status=0')­;"

scriptstring +=
"WinPrint.document.write(prtCo­ntent.innerHTML);"
scriptstring += "WinPrint.document.close();"
scriptstring += "WinPrint.focus();"
scriptstring += "WinPrint.print();"
scriptstring += "WinPrint.close();"
scriptstring += "prtContent.innerHTML=strOldOn­e; }"
scriptstring += "</script>"


If (Not Page.IsClientScriptBlockRegist­ered("clientScript"))
Then
Page.RegisterClientScriptBlock­("clientScript",
scriptstring)
End If
End Sub


The datalist is enclosed in a <DIV id="divprint"> </DIV> tag.
And each item within has it's own style, eg
<ItemTemplate>
<div class="Title">
<%# DataBinder.Eval(Container.DataItem, "itmTitle") %>
</div>


Thanks,
Bob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,087
Latest member
JeremyMedl

Latest Threads

Top