468,532 Members | 1,632 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,532 developers. It's quick & easy.

User controls and disappearing values

Jim
I have a user control that I am dynamically loading into an aspx page. When
I fill out the text boxes and submit the form using a command button on the
aspx page I lose the value from the user control. I have an Error-checking
function in the user control that I invoke from the aspx page. This method
fires and detects an error even though I fill the the text box with text.
Now, if I fill out the text box again with text everything goes smooth
sailing and I am able to continue. I am loading the user control using the
following methodology:

tenant_setup.scheduling.userbehaveproblems userBehaveProblem = new
tenant_setup.scheduling.userbehaveproblems();//form level variable declaration
userBehaveProblem = LoadControl ("userbehaveproblems.ascx") as
tenant_setup.scheduling.userbehaveproblems;//gets an instance of the control

pnlUserControl.Controls.Add (userBehaveProblem);//loads the control in the
panel
userBehaveProblem.HasErrors ();//the method call

I think it is a state problem, and I have the view state enabled. Any
suggestions?

Nov 18 '05 #1
6 1604
Jim, behind what event are you loading the user control, and are you doing it
on every postback?

"Jim" wrote:
I have a user control that I am dynamically loading into an aspx page. When
I fill out the text boxes and submit the form using a command button on the
aspx page I lose the value from the user control. I have an Error-checking
function in the user control that I invoke from the aspx page. This method
fires and detects an error even though I fill the the text box with text.
Now, if I fill out the text box again with text everything goes smooth
sailing and I am able to continue. I am loading the user control using the
following methodology:

tenant_setup.scheduling.userbehaveproblems userBehaveProblem = new
tenant_setup.scheduling.userbehaveproblems();//form level variable declaration
userBehaveProblem = LoadControl ("userbehaveproblems.ascx") as
tenant_setup.scheduling.userbehaveproblems;//gets an instance of the control

pnlUserControl.Controls.Add (userBehaveProblem);//loads the control in the
panel
userBehaveProblem.HasErrors ();//the method call

I think it is a state problem, and I have the view state enabled. Any
suggestions?

Nov 18 '05 #2
Jim
I am loading the controls off of a combo box post back, but I am not
reloading the user control after the command button click event is fired. I
assumed since I declare the user controls as being form level I would not
have to.

"Bill Borg" wrote:
Jim, behind what event are you loading the user control, and are you doing it
on every postback?

"Jim" wrote:
I have a user control that I am dynamically loading into an aspx page. When
I fill out the text boxes and submit the form using a command button on the
aspx page I lose the value from the user control. I have an Error-checking
function in the user control that I invoke from the aspx page. This method
fires and detects an error even though I fill the the text box with text.
Now, if I fill out the text box again with text everything goes smooth
sailing and I am able to continue. I am loading the user control using the
following methodology:

tenant_setup.scheduling.userbehaveproblems userBehaveProblem = new
tenant_setup.scheduling.userbehaveproblems();//form level variable declaration
userBehaveProblem = LoadControl ("userbehaveproblems.ascx") as
tenant_setup.scheduling.userbehaveproblems;//gets an instance of the control

pnlUserControl.Controls.Add (userBehaveProblem);//loads the control in the
panel
userBehaveProblem.HasErrors ();//the method call

I think it is a state problem, and I have the view state enabled. Any
suggestions?

Nov 18 '05 #3
If the control and its textbox are not there after postback, there's no place
for the text you just entered to return to. Try loading the control each
time. Curious, in this case, how are you invoking the error-checking function
after postback if that control doesn't exist?

Bill

"Jim" wrote:
I am loading the controls off of a combo box post back, but I am not
reloading the user control after the command button click event is fired. I
assumed since I declare the user controls as being form level I would not
have to.

"Bill Borg" wrote:
Jim, behind what event are you loading the user control, and are you doing it
on every postback?

"Jim" wrote:
I have a user control that I am dynamically loading into an aspx page. When
I fill out the text boxes and submit the form using a command button on the
aspx page I lose the value from the user control. I have an Error-checking
function in the user control that I invoke from the aspx page. This method
fires and detects an error even though I fill the the text box with text.
Now, if I fill out the text box again with text everything goes smooth
sailing and I am able to continue. I am loading the user control using the
following methodology:

tenant_setup.scheduling.userbehaveproblems userBehaveProblem = new
tenant_setup.scheduling.userbehaveproblems();//form level variable declaration
userBehaveProblem = LoadControl ("userbehaveproblems.ascx") as
tenant_setup.scheduling.userbehaveproblems;//gets an instance of the control

pnlUserControl.Controls.Add (userBehaveProblem);//loads the control in the
panel
userBehaveProblem.HasErrors ();//the method call

I think it is a state problem, and I have the view state enabled. Any
suggestions?

Nov 18 '05 #4
Jim
I think you may have misunderstood. The user control is there, just not the
value that I typed into the text box of the user control.

"Bill Borg" wrote:
If the control and its textbox are not there after postback, there's no place
for the text you just entered to return to. Try loading the control each
time. Curious, in this case, how are you invoking the error-checking function
after postback if that control doesn't exist?

Bill

"Jim" wrote:
I am loading the controls off of a combo box post back, but I am not
reloading the user control after the command button click event is fired. I
assumed since I declare the user controls as being form level I would not
have to.

"Bill Borg" wrote:
Jim, behind what event are you loading the user control, and are you doing it
on every postback?

"Jim" wrote:

> I have a user control that I am dynamically loading into an aspx page. When
> I fill out the text boxes and submit the form using a command button on the
> aspx page I lose the value from the user control. I have an Error-checking
> function in the user control that I invoke from the aspx page. This method
> fires and detects an error even though I fill the the text box with text.
> Now, if I fill out the text box again with text everything goes smooth
> sailing and I am able to continue. I am loading the user control using the
> following methodology:
>
> tenant_setup.scheduling.userbehaveproblems userBehaveProblem = new
> tenant_setup.scheduling.userbehaveproblems();//form level variable declaration
>
>
> userBehaveProblem = LoadControl ("userbehaveproblems.ascx") as
> tenant_setup.scheduling.userbehaveproblems;//gets an instance of the control
>
> pnlUserControl.Controls.Add (userBehaveProblem);//loads the control in the
> panel
>
>
> userBehaveProblem.HasErrors ();//the method call
>
> I think it is a state problem, and I have the view state enabled. Any
> suggestions?
>

Nov 18 '05 #5
If I'm understanding you right, you are doing the loadcontrol in the
selectionchanged event of the combo box (autopostback=true), e.g.

panel1.Controls.Add(LoadControl("test.ascx"))

Is that right? If so, that control only *looks* like it's there (you see it
on the screen), but it's not *really* there after the next postback (e.g. the
button click), because everything starts from scratch again on the page load.

Not sure if you have a wide variety of user controls you're adding, but if
the number is small you might consider putting them *all* on the panel at
design-time, then let your combobox set visible on/off for the ones you want.

Let me know if this helps or if I'm still missing something.

Bill

"Jim" wrote:
I think you may have misunderstood. The user control is there, just not the
value that I typed into the text box of the user control.

"Bill Borg" wrote:
If the control and its textbox are not there after postback, there's no place
for the text you just entered to return to. Try loading the control each
time. Curious, in this case, how are you invoking the error-checking function
after postback if that control doesn't exist?

Bill

"Jim" wrote:
I am loading the controls off of a combo box post back, but I am not
reloading the user control after the command button click event is fired. I
assumed since I declare the user controls as being form level I would not
have to.

"Bill Borg" wrote:

> Jim, behind what event are you loading the user control, and are you doing it
> on every postback?
>
> "Jim" wrote:
>
> > I have a user control that I am dynamically loading into an aspx page. When
> > I fill out the text boxes and submit the form using a command button on the
> > aspx page I lose the value from the user control. I have an Error-checking
> > function in the user control that I invoke from the aspx page. This method
> > fires and detects an error even though I fill the the text box with text.
> > Now, if I fill out the text box again with text everything goes smooth
> > sailing and I am able to continue. I am loading the user control using the
> > following methodology:
> >
> > tenant_setup.scheduling.userbehaveproblems userBehaveProblem = new
> > tenant_setup.scheduling.userbehaveproblems();//form level variable declaration
> >
> >
> > userBehaveProblem = LoadControl ("userbehaveproblems.ascx") as
> > tenant_setup.scheduling.userbehaveproblems;//gets an instance of the control
> >
> > pnlUserControl.Controls.Add (userBehaveProblem);//loads the control in the
> > panel
> >
> >
> > userBehaveProblem.HasErrors ();//the method call
> >
> > I think it is a state problem, and I have the view state enabled. Any
> > suggestions?
> >

Nov 18 '05 #6
Jim
Yah, I have approximately 40 different controls that I need to be able to
load, so I will just come up with something in the command button click
event. Thanks for all of your help, however.

"Bill Borg" wrote:
If I'm understanding you right, you are doing the loadcontrol in the
selectionchanged event of the combo box (autopostback=true), e.g.

panel1.Controls.Add(LoadControl("test.ascx"))

Is that right? If so, that control only *looks* like it's there (you see it
on the screen), but it's not *really* there after the next postback (e.g. the
button click), because everything starts from scratch again on the page load.

Not sure if you have a wide variety of user controls you're adding, but if
the number is small you might consider putting them *all* on the panel at
design-time, then let your combobox set visible on/off for the ones you want.

Let me know if this helps or if I'm still missing something.

Bill

"Jim" wrote:
I think you may have misunderstood. The user control is there, just not the
value that I typed into the text box of the user control.

"Bill Borg" wrote:
If the control and its textbox are not there after postback, there's no place
for the text you just entered to return to. Try loading the control each
time. Curious, in this case, how are you invoking the error-checking function
after postback if that control doesn't exist?

Bill

"Jim" wrote:

> I am loading the controls off of a combo box post back, but I am not
> reloading the user control after the command button click event is fired. I
> assumed since I declare the user controls as being form level I would not
> have to.
>
> "Bill Borg" wrote:
>
> > Jim, behind what event are you loading the user control, and are you doing it
> > on every postback?
> >
> > "Jim" wrote:
> >
> > > I have a user control that I am dynamically loading into an aspx page. When
> > > I fill out the text boxes and submit the form using a command button on the
> > > aspx page I lose the value from the user control. I have an Error-checking
> > > function in the user control that I invoke from the aspx page. This method
> > > fires and detects an error even though I fill the the text box with text.
> > > Now, if I fill out the text box again with text everything goes smooth
> > > sailing and I am able to continue. I am loading the user control using the
> > > following methodology:
> > >
> > > tenant_setup.scheduling.userbehaveproblems userBehaveProblem = new
> > > tenant_setup.scheduling.userbehaveproblems();//form level variable declaration
> > >
> > >
> > > userBehaveProblem = LoadControl ("userbehaveproblems.ascx") as
> > > tenant_setup.scheduling.userbehaveproblems;//gets an instance of the control
> > >
> > > pnlUserControl.Controls.Add (userBehaveProblem);//loads the control in the
> > > panel
> > >
> > >
> > > userBehaveProblem.HasErrors ();//the method call
> > >
> > > I think it is a state problem, and I have the view state enabled. Any
> > > suggestions?
> > >

Nov 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by neptune | last post: by
4 posts views Thread by Steve | last post: by
2 posts views Thread by Rachel Suddeth | last post: by
3 posts views Thread by Oddball | last post: by
1 post views Thread by Robert Howells | last post: by
7 posts views Thread by clintonG | last post: by
6 posts views Thread by George Yefchak | last post: by
3 posts views Thread by ARayB | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.