Control Not remembering property on postback

T

Teemu Keiski

Hi,

where in the lifecycle / events you reading/writing the value? Init, Load,
postback event, PreRender...?
 
C

Chris Kennedy

I am having problems getting my customer control to remember properties
accross postback. I have tried setting it to a session. What is the
recommended way of doing this.

I have tried this
'set it to session
_location = Value.ToString()
System.Web.HttpContext.Current.Session("XmlPath") = _location

'on the postback where I have the problem if the location is empty read in
the session

if _location = "" then
_location = System.Web.HttpContext.Current.Session("XmlPath")
end if
 
T

Teemu Keiski

If I understand correctly what you mean (just in member declarations), then
yes, it could be the reason. Try setting it in some event like Load (it just
should be set before accessed).

Are you still reading it normally in some event?.
 
C

Chris Kennedy

I am just setting the property in the public declarations like with any
object. This is in any event. Is this where I am going wrong?
 
C

Chris Kennedy

The property is set in the Load event of the parent page. It's just on
postback the control doesn't remember the property?

The control has some control and a button control. I have added an event to
the button click. When I try to access the property in the onCLick event it
can't find the property.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top