Hotwired Printer Friendly Page

B

Beavis

Ok, so I wanted to make a printerfriendly page for our site. However,
we don't know exactly which pages all need to have the printerfriendly
option or not. So, instead of making custom printerfriendly pages over
and over again, I wanted to do some sneaky stuff in my Print.aspx page
that would instantiate the page that we wanted to print, let the Pages
LifeCycle complete, then grab a particular group of Controls and put
them into the Print.aspx pages control collection. The problem is that
when I Dynamically instantiate the page object using
Activator.CreateInstance, the page that I create has an empty control
collection (count is 0). I cannot figure out how to tell the site that
the page that I instantiated needs to have it's code called.

My other option is to modify the MasterPage and BasePages that we have
to know enough to remove all of the MasterPage and/or BasePage common
content (IE navigation links, etc). I don't know which option is
better, but I do know that this code could not really be shared in the
MasterPage and BasePage, thus doubling the work/maintanence.

Here is what I have thus far:

public partial class Print
{
Page _myPage = null;
protected void Page_Load(object sender, EventArgs e)
{
//string className = Request.QueryString["className"];
//Hard Code for debugging
string className =
"Namespace.Namespace.Namespace.Folder.PageClassName";
_myPage = InstiantiatePage(className);
this.Page = _myPage;

//_myPage.Controls.Count equals 0 here

}
private Page InstiantiatePage(string className)
{
Page ret = null;
object[] arr = {};
ret =
(Page)Activator.CreateInstance(System.Type.GetType(className), arr);
return ret;
}
}


Thanks in advance!
 
B

Beavis

If anyone else is looking into doing something similar, it is actually
possible with a javascript popup that calls
document.write(window.opener.getElementByID("contentDiv").innerHTML);

or something similar, I haven't actually done it yet, but I am sure
that it will work...

AB
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top