Dynamic Page (Page.ParseControls Caching)

  • Thread starter Thread starter JT-ARL
  • Start date Start date
J

JT-ARL

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
 
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)
 
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
 
Back
Top