Groups | Blog | Home
all groups > asp.net building controls > october 2003 >

asp.net building controls : User control problem


Niranjan
10/30/2003 12:12:57 AM
Hi,

I am having a user control (yesno) which shows "yes"
and "no" options in a combo box. I have also set caching
as 1 day for this user control. This control i am using in
another user control (parent user control) for 5 times. I
have properties to access individual controls.
When I access the parent user control in a page, I am not
able to refer to the 2nd level child user control. they
are visible in the page, but when i refer them, the object
is set to null.
When i remove the caching, i am able to access the child
controls, else I am not.
Can anyone help how to solve this problem without removing
the output caching in yesno user control.

thanks
John Saunders
10/30/2003 5:11:39 PM
[quoted text, click to view]

At what point in your code are you trying to access the properties which
refer to the 2nd level user controls? It sounds like you're doing so much
too early in the page lifecycle.
--
John

Niranjan Kumar
10/30/2003 7:31:28 PM
John,

I am trying to access the 2nd level controls in post back
of Page_Load() of the web page.
The problem is due to caching. the 2nd level user controls
are cached and they are not created in the post back,
since they are already cached.

Thanks
Niranjan

[quoted text, click to view]
John Saunders
10/31/2003 1:19:33 PM
[quoted text, click to view]

Yes, sorry, I didn't catch that part.

If you use output caching, you're stating that the previous output of the
user control is adequate, that you don't need the user control to be
instantiated and executed again. But in your case, you _do_ need the control
to be instantiated and executed again. You'll have to remove the caching or
else put the information which had been inside of the user control into a
Session variable or something else which will exist when you want it to.
--
John

AddThis Social Bookmark Button