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

dataset to RTF format in browser and then javascript print

in a previous aspx page i got a few records printed throu window.print()
function in javascript.

but now i have the records in a to RTF and i want to run the same function
print, which ofcourse wont work
since the page isnt HTML anymore. Is there some other way to print
automaticly.

i used to have this function to print automaticly from a browser to client.
------------------

<BODY onload="doPrint()">
<object id="WBControl" width="0" height="0"
classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>

<script language="VBScript"><!--
Sub VBPrint() On Error Resume Next
WBControl.ExecWB 6,1
End Sub
//--></script>

<script language=JavaScript><!--
function doPrint()
{
if(self.print)
{
self.print();
self.close();
return false;

}
else if (navigator.appName.indexOf('Microsoft') != -1)
{
VBPrint();
self.close();
}
else
{
alert("To print this document, you will need to\nclick the Right Mouse
Button and select\n'Print'");
}
}
//-->
</script>

--------------
which made sure the page is printed without having a user asked for a
confirmation but i want the same this but for an RTF document.
my code is:
-------------------
Dim myConnection As OleDBConnection = New
OleDBConnection(AppSettings("DigifanDatabaseCon"))
myConnection.Open()

Dim ds As DataSet
Dim sXSL As String

ds = New DataSet("klantenkaart")
Dim ContactsDA As OleDBDataAdapter = New OleDBDataAdapter("SELECT *
FROM Klantenbestand WHERE klantnummer="& Request.QueryString("ID") & "",
myConnection)
ContactsDA.Fill(ds, "Klantenbestand")
' XSLT to use for transforming this dataset.
sXSL = "klantenkaart.xslt"

' Close the connection to the data source.
myConnection.Close()
' Transform the dataset by using the appropriate stylesheet.
Dim xmlDoc As XmlDataDocument = New XmlDataDocument(ds)
Dim xslTran As XslTransform = New XslTransform
xslTran.Load(Server.MapPath(sXSL))

' Stream the results of the transformation to Word.
Response.ContentType = "application/msword"
Response.Charset = ""
Response.ContentEncoding = System.Text.Encoding.Default
xslTran.Transform(xmlDoc, Nothing, Response.Output)

-------------------
and i want to print it then but how. I am kinda stuck.
i hope it makes sence to the person reading it and thx in advance if you can
help me out.

Richard
Nov 18 '05 #1
3 2355
Hi Richard,

From your description, you output a Word Document to the client user in a
certain web page's response stream. And you found you're unable to use
window.print() script code to print the page now, yes?

As for this problem, it is because when you render out a page as a word
document, the contenttype is changed to "application/msword" rather than
the standard "text/html" , so there is no html also script code in the
response content. And we can't call the script code to print the page from
itself. However, I think we can use another means to workaround this, we
can define a container page which contains a <iframe > element (set width
and height to 100%) , and set the iframe's src attribute to the page which
return the Word document. Then, we can use script code in the container
page to print the iframe page(which is host the word document). For
example, in the container page we define the following iframe:

<iframe id="innerFrame" src="worddoc.aspx"/>

Then, we can provide the following script function:
function printInnerDoc()
{
window.frames[0].print();
}

And use it in the container page's onload event, such as
<body onload="printInnerDoc()">

Please have a try and if you have any other ideas, please also feel free
to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
Nov 18 '05 #2
Holy crap, that actually worked, thx Steven you rock. This helps me solve a
lot of printing issue's! thx a lot :D

Richard

"Steven Cheng[MSFT]" <v-******@online.microsoft.com> schreef in bericht
news:w0**************@cpmsftngxa10.phx.gbl...
Hi Richard,

From your description, you output a Word Document to the client user in a
certain web page's response stream. And you found you're unable to use
window.print() script code to print the page now, yes?

As for this problem, it is because when you render out a page as a word
document, the contenttype is changed to "application/msword" rather than
the standard "text/html" , so there is no html also script code in the
response content. And we can't call the script code to print the page from
itself. However, I think we can use another means to workaround this, we
can define a container page which contains a <iframe > element (set width
and height to 100%) , and set the iframe's src attribute to the page which
return the Word document. Then, we can use script code in the container
page to print the iframe page(which is host the word document). For
example, in the container page we define the following iframe:

<iframe id="innerFrame" src="worddoc.aspx"/>

Then, we can provide the following script function:
function printInnerDoc()
{
window.frames[0].print();
}

And use it in the container page's onload event, such as
<body onload="printInnerDoc()">

Please have a try and if you have any other ideas, please also feel free
to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3
Hi Richard,

Thanks for your response. My Pleasure!:)

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #4

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

Similar topics

4
by: peashoe | last post by:
I have an asp page that uses a calendar.js (pop-up) file to add an exact date format in the text field (txtDDate). My problem is I need some javascript that sets an alert that does not allow them...
6
by: Biguana | last post by:
Hi, Just wondering if anyone can help here. We have a site where most of the site opens in a window with no toolbars or menubar: window.open('mypage.aspx','self','toolbar=0, menubar=0, etc,...
4
by: suzy | last post by:
hello. how can i sort data in a dataset? all the examples i have seen on msdn, etc are sorting a dataview. this works fine, but i want to return the results in xml and the dataview doesn't...
3
by: jayuya | last post by:
Can anyone give a sample code, tip, or a web link with an example of how to format data to currency. eg: $3451.25 I set a dataadapter and I fill the dataset from a SQL Statement, but some...
2
by: Martin | last post by:
Hi! I'm new to ASP.NET WebApplications and wonder whether I've missed something out when programming it. I'm grateful for any hints to this problem! Thanks very much for your efforts! Martin...
14
by: askMe | last post by:
I developed a web page that plays an mpg using the simple embed tag. When the page loads, the video starts, but then stops after a few seconds. I use the embed tag because I want the user's...
3
by: nashak | last post by:
Hello, ASP.NET pages are disconnected html pages i.e once page is sent to the browser, that is it. Let's say that I have a datagrid on my page and I have used a dataset to fill this grid only...
13
by: David W. Fenton | last post by:
I've been struggling the last two days with something I thought was very easy, which is to open a web page with a form on it and populate the form with data passed in a query string (either POST or...
41
by: Cartoper | last post by:
I hear it is possible to disable the web browsers print function, does anyone know how to do that?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.