<asp:label> reverting to initial value

M

mark.norgate

Why oh why does my <asp:label> revert to its initial value, having been
changed programmatically, when I click a button in a user control I
have added dynamically to the page? It's EnableViewState is set to
true.

Mark
 
M

Mark Rae

Why oh why does my <asp:label> revert to its initial value, having been
changed programmatically, when I click a button in a user control I
have added dynamically to the page? It's EnableViewState is set to
true.

How is it being populated initially...?
 
R

Ramu

Did you forget to use IsPostBack to avoid re-initialization?

OR

If the control is dynamically added control, then add the control on
Page PreInit, such that view state will be populated for the control.
Controls view state will be populated on subsequent TrackViewState
call.

Hth,
Ramu
 
M

mark.norgate

It is being populated on the .aspx page directly, using the Text
attribute of the Label class. I'm not setting its initial value in
code.

Mark
 
M

mark.norgate

Neither of those applies, since it's initial value is not set it code,
and it is not dynamically added.

Mark
 

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,781
Messages
2,569,619
Members
45,310
Latest member
FaustoMont

Latest Threads

Top