Dynamic Page (Page.ParseControls Caching)

Discussion in 'ASP .Net' started by JT-ARL, Oct 17, 2008.

  1. JT-ARL

    JT-ARL Guest

    I have a pretty tricky problem. I have a dynamically built page. I use
    Page.ParseControls to parse the "entire page" (ASPX file contains only a Page
    tag). ParseControls is pretty resource intensive so I would like to cache
    the Page.Controls collection and reuse it on postback instead of issuing
    page.parsecontrols on the source again. When I cache the Controls collection
    and add the controls back to the page, the Page.Form property is null (I
    don't exactly know why but there does not appear to be a way to initialize
    it). I have been unable to find a solutions to this and any approaches
    would be helpful. There is a form control in the controls collection but
    again it is not registered with the page.


    Thanks,
    Justin
     
    JT-ARL, Oct 17, 2008
    #1
    1. Advertising

  2. JT-ARL

    bruce barker Guest

    this can not really be done. controls can not be reused between pages as few
    if any are written to support running the page cycle twice. this is why
    asp.net caches the output rather than the control.

    you could parse it once, and use the control tree as a template. make copies
    of each control and add to page. you would have to write a clone routine for
    each control you use.

    or you coudl switch to using LoadControl. which build a class file on the
    first call, and resues it, so parses are no longer necessary.

    -- bruce (sqlwork.com)


    "JT-ARL" wrote:

    > I have a pretty tricky problem. I have a dynamically built page. I use
    > Page.ParseControls to parse the "entire page" (ASPX file contains only a Page
    > tag). ParseControls is pretty resource intensive so I would like to cache
    > the Page.Controls collection and reuse it on postback instead of issuing
    > page.parsecontrols on the source again. When I cache the Controls collection
    > and add the controls back to the page, the Page.Form property is null (I
    > don't exactly know why but there does not appear to be a way to initialize
    > it). I have been unable to find a solutions to this and any approaches
    > would be helpful. There is a form control in the controls collection but
    > again it is not registered with the page.
    >
    >
    > Thanks,
    > Justin
     
    bruce barker, Oct 17, 2008
    #2
    1. Advertising

  3. JT-ARL

    JT-ARL Guest

    Bruce,
    Thanks for your reply. I think the clone routines would work, lot of work
    but they would probably work. As for the LoadControl method, doesn't this
    require an actual usercontrol to be created or am I missing something.

    Thanks again,
    Justin

    "bruce barker" wrote:

    > this can not really be done. controls can not be reused between pages as few
    > if any are written to support running the page cycle twice. this is why
    > asp.net caches the output rather than the control.
    >
    > you could parse it once, and use the control tree as a template. make copies
    > of each control and add to page. you would have to write a clone routine for
    > each control you use.
    >
    > or you coudl switch to using LoadControl. which build a class file on the
    > first call, and resues it, so parses are no longer necessary.
    >
    > -- bruce (sqlwork.com)
    >
    >
    > "JT-ARL" wrote:
    >
    > > I have a pretty tricky problem. I have a dynamically built page. I use
    > > Page.ParseControls to parse the "entire page" (ASPX file contains only a Page
    > > tag). ParseControls is pretty resource intensive so I would like to cache
    > > the Page.Controls collection and reuse it on postback instead of issuing
    > > page.parsecontrols on the source again. When I cache the Controls collection
    > > and add the controls back to the page, the Page.Form property is null (I
    > > don't exactly know why but there does not appear to be a way to initialize
    > > it). I have been unable to find a solutions to this and any approaches
    > > would be helpful. There is a form control in the controls collection but
    > > again it is not registered with the page.
    > >
    > >
    > > Thanks,
    > > Justin
     
    JT-ARL, Oct 17, 2008
    #3
    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. Hypo
    Replies:
    6
    Views:
    463
  2. Martin

    Output caching dynamic pages

    Martin, Jan 4, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    746
    Martin
    Jan 4, 2004
  3. Troy Simpson

    Fragment Caching inside page caching?

    Troy Simpson, Jan 19, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    844
    Troy Simpson
    Jan 19, 2004
  4. Neal  Terrell

    Caching of dynamic images

    Neal Terrell, Apr 4, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    439
    Neal Terrell
    Apr 4, 2006
  5. JimLad
    Replies:
    3
    Views:
    950
    JimLad
    Jan 21, 2010
Loading...

Share This Page