User control problem

N

Niranjan

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

John Saunders

Niranjan said:
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.

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.
 
N

Niranjan Kumar

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
 
J

John Saunders

Niranjan Kumar said:
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.

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.
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top