Hello,
Here is the client script I want to execute. It
basically serves to make a page "printer friendly".
function PrintThisPage()
{
var
sOption="toolbar=yes,location=no,directories=yes,menubar=yes,";
sOption+="scrollbars=yes,width=750,height=600,left=100,top=25";
var sWinHTML =
document.getElementById('contentstart').innerHTML;
var winprint=window.open("","_top",sOption);
winprint.document.open();
winprint.document.write('<html><LINK
href=/eggheadcafe.css rel=Stylesheet><body>');
winprint.document.write(sWinHTML);
winprint.document.write('</body></html>');
winprint.document.close();
winprint.focus();
}
I created an image button as follows
<asp:imagebutton id="imgPrint" runat="server"
ImageUrl="images/b_print_friend.gif"></asp:imagebutton>
and my server side code is
Private Sub imgPrint_Click(ByVal sender As Object,
ByVal e As System.Web.UI.ImageClickEventArgs) Handles
imgPrint.Click
imgBack4.Visible = False
imgSubmit.Visible = False
imgSave5.Visible = False
imgPrint.Visible = False
Dim script As String
script += " script += "function PrintThisPage() <br> "
script += "{ <br>"
script += "var
sOption='toolbar=yes,location=no,directories=yes,menubar=yes,';
<br>"
script +=
"sOption+='scrollbars=yes,width=750,height=600,left=100,top=25';
<br>"
script += "var sWinHTML =
document.getElementById('contentstart').innerHTML;
<br>"
script += "var
winprint=window.open('','_top',sOption); <br>"
script += "winprint.document.open(); <br>"
script +=
"winprint.document.write('<html><LINK
href=/eggheadcafe.css rel=Stylesheet><body>'); <br>"
script += "winprint.document.write(sWinHTML);
<br>"
script +=
"winprint.document.write('</body></html>'); <br> "
script += "winprint.document.close(); <br> "
script += "winprint.focus(); <br>"
script += " } <br> "
script += "</script>"
If Not
IsClientScriptBlockRegistered("PrintThisPage") Then
RegisterClientScriptBlock("PrintThisPage",
script)
End If
End Sub
but nothing is happening on the client side. Do I have
to do something else to execute this script?
Would appreciate your help.
Thank you,
Burak
Here is the client script I want to execute. It
basically serves to make a page "printer friendly".
function PrintThisPage()
{
var
sOption="toolbar=yes,location=no,directories=yes,menubar=yes,";
sOption+="scrollbars=yes,width=750,height=600,left=100,top=25";
var sWinHTML =
document.getElementById('contentstart').innerHTML;
var winprint=window.open("","_top",sOption);
winprint.document.open();
winprint.document.write('<html><LINK
href=/eggheadcafe.css rel=Stylesheet><body>');
winprint.document.write(sWinHTML);
winprint.document.write('</body></html>');
winprint.document.close();
winprint.focus();
}
I created an image button as follows
<asp:imagebutton id="imgPrint" runat="server"
ImageUrl="images/b_print_friend.gif"></asp:imagebutton>
and my server side code is
Private Sub imgPrint_Click(ByVal sender As Object,
ByVal e As System.Web.UI.ImageClickEventArgs) Handles
imgPrint.Click
imgBack4.Visible = False
imgSubmit.Visible = False
imgSave5.Visible = False
imgPrint.Visible = False
Dim script As String
script += " script += "function PrintThisPage() <br> "
script += "{ <br>"
script += "var
sOption='toolbar=yes,location=no,directories=yes,menubar=yes,';
<br>"
script +=
"sOption+='scrollbars=yes,width=750,height=600,left=100,top=25';
<br>"
script += "var sWinHTML =
document.getElementById('contentstart').innerHTML;
<br>"
script += "var
winprint=window.open('','_top',sOption); <br>"
script += "winprint.document.open(); <br>"
script +=
"winprint.document.write('<html><LINK
href=/eggheadcafe.css rel=Stylesheet><body>'); <br>"
script += "winprint.document.write(sWinHTML);
<br>"
script +=
"winprint.document.write('</body></html>'); <br> "
script += "winprint.document.close(); <br> "
script += "winprint.focus(); <br>"
script += " } <br> "
script += "</script>"
If Not
IsClientScriptBlockRegistered("PrintThisPage") Then
RegisterClientScriptBlock("PrintThisPage",
script)
End If
End Sub
but nothing is happening on the client side. Do I have
to do something else to execute this script?
Would appreciate your help.
Thank you,
Burak