Hotwired Printer Friendly Page

Discussion in 'ASP .Net' started by Beavis, Dec 6, 2006.

  1. Beavis

    Beavis Guest

    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!
     
    Beavis, Dec 6, 2006
    #1
    1. Advertising

  2. Beavis

    Beavis Guest

    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
     
    Beavis, Dec 13, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Klucker

    implementing a Printer Friendly .aspx Page

    John Klucker, Aug 15, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    423
    John Timney \(Microsoft MVP\)
    Aug 15, 2003
  2. =?Utf-8?B?VGlnZ2Vy?=
    Replies:
    2
    Views:
    489
    =?Utf-8?B?SmVyZW15IERhdmlz?=
    Nov 10, 2004
  3. =?Utf-8?B?SmltIEg=?=

    Printer Friendly Page

    =?Utf-8?B?SmltIEg=?=, Jul 1, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    465
  4. Yog
    Replies:
    0
    Views:
    479
  5. tommy
    Replies:
    2
    Views:
    125
Loading...

Share This Page