Y
yer darn tootin
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,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>"
'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.
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,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>"
'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.