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("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,height=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>"
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.
And each item within has it's own style, eg
<ItemTemplate>
<div class="Title">
<%# DataBinder.Eval(Container.DataItem, "itmTitle") %>
</div>
Thanks,
Bob
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("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,height=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>"
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.
And each item within has it's own style, eg
<ItemTemplate>
<div class="Title">
<%# DataBinder.Eval(Container.DataItem, "itmTitle") %>
</div>
Thanks,
Bob