Quote:
Originally Posted by frankiefrank
Yes I understand that I don't want to create a temporary HTML file. What I wanted to do is just create a new window in js, then use window.document to access the HTML DOM and write into the innerHTML the string that I build on the server.
The reason for building the string on the server is that I already have methods that collect parameters from the aspx page controls on the server side, so it's easier for me to iterate through these parameters on the server-side. I just need to somehow pass the constructed string into the js so that I can use it in the innerHTML of the new window's document.
I'm not the greatest with JavaScript so maybe what you're trying to do is possible...I'm not sure how you plan on displaying HTML in a new browser window without hosting that HTML on the web server.....
But anyways, I'll answer your question now:
To pass the string between the JavaScript and .NET code you can use a hidden field. You need to register the hidden field using your Page's ClientScript property:
-
Page.ClientScript.RegisterHiddenField("hiddenVariableName","hiddenVariableValue")
-
Now that you know the name of the hidden variable, you can access your server generated string in your JavaScript.
Quote:
Originally Posted by frankiefrank
I'm looking into the CSS direction too, already started checking but can you please expand on how i would "apply the css" to the page
You would apply the CSS as you would normally
apply CSS to a web page....
CSS2 has some printing styles that help you to format your web page so that it is printer friendly. I suggest looking up
CSS2 (or even just CSS in general) to understand how to use these tools for your benifit.
Quote:
Originally Posted by frankiefrank
I have an aspx with a gridview (paged and sorted) and I want to display it in a new page - typical Print Preview situation. ...
....and where does turning off the paging come in?
I was under the impression that your report GridView's paging capabilities are the cause of your printing problems...
Earlier I recommended that you add a "Print Preview" button to your aspx Report page.
When the user clicked this button, you would format your page so that it was printer friendly.
While you were formatting the page (in the button click event), you would have disabled the GridView's paging so that the whole report would be shown.
Also during that formatting stage you'd make invisible the things you didn't want the user to see in their printed copy.
Using this method might still be a good idea for you.
In your ASPX page you could check if the user is in "Print Preview" mode or not.
This way, when the user clicked "Print Preview" you could open a new browser window that called your ASPX page again passing it a parameter that indicated that it was in "Print Preview Mode"....the ASPX would be displayed in a printer friendly version in a new window....
Then you don't need to do anything with temporary html...you'd just be using 1 ASPX page...and since the ASPX page already knows how to generate the report, away you go....
-Frinny