Dynamic Page (Page.ParseControls Caching)

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
 
B

bruce barker

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)
 
J

JT-ARL

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
 

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

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top