Ask a Question related to ASP.NET General, Design and Development.
-
Bisser Milanov #1
why controls keep their state even on a different page?
I have
1. A main form with 2 buttons (btn1 and btn2) and a place holder (ph)
2. A Web User Control (ctl1) containing a textbox (txt)
3. A Web User Control (ctl2) containing a textbox (txt)
When I press btn1 I have the following code:
ph.Controls.Add(LoadControl("ctl1.ascx"))
When I press btn2 I have the following code:
ph.Controls.Add(LoadControl("ctl2.ascx"))
In ctl1 I have the following line on form load:
txt.Enabled = False
When I press btn1 ctl1 is loaded and the txt is disabled. When I press btn2
ctl2 is loaded and the txt is disabled. Why the txt on ctl2 is disabled? and
how can I avoid it? Somehow it remembered the state of the textbox from the
previous loaded page. Why?
Bisser Milanov Guest
-
Maintaining state in programmatically created composite user controls
Hi I'm writing a timesheet application in ASP.NET (framework 1.1, VS 2003) that includes a user control to manage project time allocation... -
Losing Postback state with composite controls
Not sure how to go about explaining this, which is never a good sign. I have a Custom UserControl I've built, which contains 1 drop-down list and... -
Maintaining View State For Dynamically Created Controls
I am building a custom control that I want to server as a container for child controls that can be dynamically added to this control. I can persist... -
Preserving state of radio controls
Hi. One custom control I am creating generates a series of radio buttons. These are html radio buttons, not the server version. When I run the... -
persist state of controls in a custom control
Specify the control to implement INamingContainer interface. Also properties that need to be preserved, example is the GroupName property, would... -
Paul Wilson [MVP] #2
Re: why controls keep their state even on a different page?
Viewstate is based on a control's position in the hierarchical control tree
and you are loading different controls into the same position each time.
You either need to setup different placeholders so that each set of controls
is loaded into a different placeholder, or manually deal with consequences.
Thanks, Paul Wilson (MVP)
Paul Wilson [MVP] Guest
-
Bisser Milanov #3
Re: why controls keep their state even on a different page?
Hm, what is the purpose of a Place Holder then? If I will load always the
same control in this placeholder I will simply put the control itself on the
page. Why would I put it into a placeholder?
I actually tried to clear the viewstate when I load different control but it
didn't work. I tried to clear the view state of the control of the main form
of the text box itself but nothing worked. Any ideas how to clear the view
state?
Bisser Milanov Guest
-
gerry #4
Re: why controls keep their state even on a different page?
forget the 'position' stuff give the conflicting controls different names
that has solved this problem for us.
"Bisser Milanov" <bm@bm.bm> wrote in message
news:uph2gyjSDHA.2228@tk2msftngp13.phx.gbl...the> Hm, what is the purpose of a Place Holder then? If I will load always the
> same control in this placeholder I will simply put the control itself onit> page. Why would I put it into a placeholder?
> I actually tried to clear the viewstate when I load different control butform> didn't work. I tried to clear the view state of the control of the main> of the text box itself but nothing worked. Any ideas how to clear the view
> state?
>
>
gerry Guest
-
Paul Wilson #5
Re: why controls keep their state even on a different page?
If you have a different placeholder for each possible user control you
may load then the relative positions will be unique. By the way, unique
control ways does not work with viewstate, although it will work if your
problem is just the posted values.
Thanks, Paul Wilson (MVP)
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Paul Wilson Guest



Reply With Quote

