473,765 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Programmaticall y added controls losing state

I've asked this question before, but still haven't solved it, so am
asking again.

I am programmaticall y adding a user control to the page in response to
a button click. The user control consists of three dropdowns and seven
text boxes.

When the button is clicked, I add another control to the page in Click
event of the button and populate the three dropdowns. The text boxes
are to be populated by the user.

All ok so far, but when I click the button again, since it is a
postback, I do not rebind the data to the dropdowns and their options
disappear, although the seven text boxes maintain their state.

Can anyone explain why this might be?

Ta, Mark

Aug 15 '06 #1
8 1994
Since the Control is dynamically added, it is not referenced in the class
definition. Since the Page class must be rebuilt from scratch with each
PostBack, the dynamically-created Control must be manually restored with
each PostBack.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Orange you bland I stopped splaying bananas?
<ma**********@g mail.comwrote in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
I've asked this question before, but still haven't solved it, so am
asking again.

I am programmaticall y adding a user control to the page in response to
a button click. The user control consists of three dropdowns and seven
text boxes.

When the button is clicked, I add another control to the page in Click
event of the button and populate the three dropdowns. The text boxes
are to be populated by the user.

All ok so far, but when I click the button again, since it is a
postback, I do not rebind the data to the dropdowns and their options
disappear, although the seven text boxes maintain their state.

Can anyone explain why this might be?

Ta, Mark

Aug 15 '06 #2
Just to add to that, you can use Denis Bauer's DynamicControls Placeholder to
hepl you do this (free):
http://www.denisbauer.com/ASPNETCont...aceholder.aspx

or you can roll the logic urself, which isn't too hard. Normally people
store the this value in the ViewState:

LoadControl("as dsa.ascx");
ViewState.Add(" ControlLoaded", true);

and then check on postback:

if (Page.IsPostBac k AND (bool)ViewState["ControlLoa ded"])
{
ReloadTheContro l();
}

if you reloadthecontro l during or before onLoad, state should be maintained.

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Kevin Spencer" <uc*@ftc.govwro te in message
news:ui******** ******@TK2MSFTN GP03.phx.gbl...
Since the Control is dynamically added, it is not referenced in the class
definition. Since the Page class must be rebuilt from scratch with each
PostBack, the dynamically-created Control must be manually restored with
each PostBack.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Orange you bland I stopped splaying bananas?
<ma**********@g mail.comwrote in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
>I've asked this question before, but still haven't solved it, so am
asking again.

I am programmaticall y adding a user control to the page in response to
a button click. The user control consists of three dropdowns and seven
text boxes.

When the button is clicked, I add another control to the page in Click
event of the button and populate the three dropdowns. The text boxes
are to be populated by the user.

All ok so far, but when I click the button again, since it is a
postback, I do not rebind the data to the dropdowns and their options
disappear, although the seven text boxes maintain their state.

Can anyone explain why this might be?

Ta, Mark


Aug 15 '06 #3
I am restoring my user control...but (some of) its child controls are
not maintaining their state. Why should the textboxes do so, but not
the dropdowns?

Mark

Kevin Spencer wrote:
Since the Control is dynamically added, it is not referenced in the class
definition. Since the Page class must be rebuilt from scratch with each
PostBack, the dynamically-created Control must be manually restored with
each PostBack.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Orange you bland I stopped splaying bananas?
<ma**********@g mail.comwrote in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
I've asked this question before, but still haven't solved it, so am
asking again.

I am programmaticall y adding a user control to the page in response to
a button click. The user control consists of three dropdowns and seven
text boxes.

When the button is clicked, I add another control to the page in Click
event of the button and populate the three dropdowns. The text boxes
are to be populated by the user.

All ok so far, but when I click the button again, since it is a
postback, I do not rebind the data to the dropdowns and their options
disappear, although the seven text boxes maintain their state.

Can anyone explain why this might be?

Ta, Mark
Aug 15 '06 #4
Karl

Would you mind explaining this in a little more detail? I'm reluctant
to use a third-party component because I want to know what the problem
is for myself so I can increase my understanding.

Why is it that some of the controls in my user control (text boxes)
maintain their state, yet others (drop downs) do not?

And I'm not entirely convinced I understand the function of the
ReloadTheContro l() method in your example, or how to distinguish one
control from another using ViewState.Add(" ControlLoaded", true), since
there many be many of these user controls on the page.

Thanks, Mark

Karl Seguin [MVP] wrote:
Just to add to that, you can use Denis Bauer's DynamicControls Placeholder to
hepl you do this (free):
http://www.denisbauer.com/ASPNETCont...aceholder.aspx

or you can roll the logic urself, which isn't too hard. Normally people
store the this value in the ViewState:

LoadControl("as dsa.ascx");
ViewState.Add(" ControlLoaded", true);

and then check on postback:

if (Page.IsPostBac k AND (bool)ViewState["ControlLoa ded"])
{
ReloadTheContro l();
}

if you reloadthecontro l during or before onLoad, state should be maintained.

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Kevin Spencer" <uc*@ftc.govwro te in message
news:ui******** ******@TK2MSFTN GP03.phx.gbl...
Since the Control is dynamically added, it is not referenced in the class
definition. Since the Page class must be rebuilt from scratch with each
PostBack, the dynamically-created Control must be manually restored with
each PostBack.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Orange you bland I stopped splaying bananas?
<ma**********@g mail.comwrote in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
I've asked this question before, but still haven't solved it, so am
asking again.

I am programmaticall y adding a user control to the page in response to
a button click. The user control consists of three dropdowns and seven
text boxes.

When the button is clicked, I add another control to the page in Click
event of the button and populate the three dropdowns. The text boxes
are to be populated by the user.

All ok so far, but when I click the button again, since it is a
postback, I do not rebind the data to the dropdowns and their options
disappear, although the seven text boxes maintain their state.

Can anyone explain why this might be?

Ta, Mark
Aug 15 '06 #5
Mark:
Textboxes are very unique in their ability to retain their state. They'll
retain their state via Request.Form, rather than the ViewState like most
(all?) other controls - that's because they are single valued. Don't be
thrown off by this unique behaviour :)

ReloadTheContro l() was just a stub function...all it would do is something
like:

Blah.Controls.A dd(Page.LoadCon trol("adsadsa.a scx"))..
if you have multiple controls, you'll need to store a more complicated
object in the viewstate...suc h as an arraylist of strings...
public void AddDynamicContr ol(string path)
{
ArrayList controlsToReloa d = (ArrayList)View State["dynamicControl s"];
if (controlsToRelo ad == null)
{
controlsToReloa d = new ArrayList();
ViewState.Add(" dynamicControls ", controlsToReloa d);
}
controlsToReloa d .Add(Path);
}

so whever you dynamically add a new control, you call AddDynamicContr ol

LoadControl("wh atever.ascx");
AddDynamicContr ol("whatever.as cx");
Then on PostBack, you can reload all the controls:

public vod ReloadDynamicCo ntrols()
{
ArrayList controslToReloa d = (ArrayList)View State["dynamicControl s"];
if (controslToRelo ad ! = null)
{
foreach (string path in controslToReloa d)
{
Page.LoadContro l(path);
}
}
}

Anyways, all of this is just some code off hte top of my head, you'll likely
need to fx it up a bit/a lot :)

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
<ma**********@g mail.comwrote in message
news:11******** **************@ 75g2000cwc.goog legroups.com...
Karl

Would you mind explaining this in a little more detail? I'm reluctant
to use a third-party component because I want to know what the problem
is for myself so I can increase my understanding.

Why is it that some of the controls in my user control (text boxes)
maintain their state, yet others (drop downs) do not?

And I'm not entirely convinced I understand the function of the
ReloadTheContro l() method in your example, or how to distinguish one
control from another using ViewState.Add(" ControlLoaded", true), since
there many be many of these user controls on the page.

Thanks, Mark

Karl Seguin [MVP] wrote:
>Just to add to that, you can use Denis Bauer's DynamicControls Placeholder
to
hepl you do this (free):
http://www.denisbauer.com/ASPNETCont...aceholder.aspx

or you can roll the logic urself, which isn't too hard. Normally people
store the this value in the ViewState:

LoadControl("a sdsa.ascx");
ViewState.Add( "ControlLoaded" , true);

and then check on postback:

if (Page.IsPostBac k AND (bool)ViewState["ControlLoa ded"])
{
ReloadTheContro l();
}

if you reloadthecontro l during or before onLoad, state should be
maintained.

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Kevin Spencer" <uc*@ftc.govwro te in message
news:ui******* *******@TK2MSFT NGP03.phx.gbl.. .
Since the Control is dynamically added, it is not referenced in the
class
definition. Since the Page class must be rebuilt from scratch with each
PostBack, the dynamically-created Control must be manually restored
with
each PostBack.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Orange you bland I stopped splaying bananas?
<ma**********@g mail.comwrote in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
I've asked this question before, but still haven't solved it, so am
asking again.

I am programmaticall y adding a user control to the page in response to
a button click. The user control consists of three dropdowns and seven
text boxes.

When the button is clicked, I add another control to the page in Click
event of the button and populate the three dropdowns. The text boxes
are to be populated by the user.

All ok so far, but when I click the button again, since it is a
postback, I do not rebind the data to the dropdowns and their options
disappear, although the seven text boxes maintain their state.

Can anyone explain why this might be?

Ta, Mark

Aug 15 '06 #6
Ok, thanks a lot for taking the time Karl.

I have found that by binding the data to the drop downs, even when
posting back, the selected values of the drop downs is maintained,
which is exactly the behaviour I want.

Thanks for your help!

Mark

Karl Seguin [MVP] wrote:
Mark:
Textboxes are very unique in their ability to retain their state. They'll
retain their state via Request.Form, rather than the ViewState like most
(all?) other controls - that's because they are single valued. Don't be
thrown off by this unique behaviour :)

ReloadTheContro l() was just a stub function...all it would do is something
like:

Blah.Controls.A dd(Page.LoadCon trol("adsadsa.a scx"))..
if you have multiple controls, you'll need to store a more complicated
object in the viewstate...suc h as an arraylist of strings...
public void AddDynamicContr ol(string path)
{
ArrayList controlsToReloa d = (ArrayList)View State["dynamicControl s"];
if (controlsToRelo ad == null)
{
controlsToReloa d = new ArrayList();
ViewState.Add(" dynamicControls ", controlsToReloa d);
}
controlsToReloa d .Add(Path);
}

so whever you dynamically add a new control, you call AddDynamicContr ol

LoadControl("wh atever.ascx");
AddDynamicContr ol("whatever.as cx");
Then on PostBack, you can reload all the controls:

public vod ReloadDynamicCo ntrols()
{
ArrayList controslToReloa d = (ArrayList)View State["dynamicControl s"];
if (controslToRelo ad ! = null)
{
foreach (string path in controslToReloa d)
{
Page.LoadContro l(path);
}
}
}

Anyways, all of this is just some code off hte top of my head, you'll likely
need to fx it up a bit/a lot :)

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
<ma**********@g mail.comwrote in message
news:11******** **************@ 75g2000cwc.goog legroups.com...
Karl

Would you mind explaining this in a little more detail? I'm reluctant
to use a third-party component because I want to know what the problem
is for myself so I can increase my understanding.

Why is it that some of the controls in my user control (text boxes)
maintain their state, yet others (drop downs) do not?

And I'm not entirely convinced I understand the function of the
ReloadTheContro l() method in your example, or how to distinguish one
control from another using ViewState.Add(" ControlLoaded", true), since
there many be many of these user controls on the page.

Thanks, Mark

Karl Seguin [MVP] wrote:
Just to add to that, you can use Denis Bauer's DynamicControls Placeholder
to
hepl you do this (free):
http://www.denisbauer.com/ASPNETCont...aceholder.aspx

or you can roll the logic urself, which isn't too hard. Normally people
store the this value in the ViewState:

LoadControl("as dsa.ascx");
ViewState.Add(" ControlLoaded", true);

and then check on postback:

if (Page.IsPostBac k AND (bool)ViewState["ControlLoa ded"])
{
ReloadTheContro l();
}

if you reloadthecontro l during or before onLoad, state should be
maintained.

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Kevin Spencer" <uc*@ftc.govwro te in message
news:ui******** ******@TK2MSFTN GP03.phx.gbl...
Since the Control is dynamically added, it is not referenced in the
class
definition. Since the Page class must be rebuilt from scratch with each
PostBack, the dynamically-created Control must be manually restored
with
each PostBack.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Orange you bland I stopped splaying bananas?
<ma**********@g mail.comwrote in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
I've asked this question before, but still haven't solved it, so am
asking again.

I am programmaticall y adding a user control to the page in response to
a button click. The user control consists of three dropdowns and seven
text boxes.

When the button is clicked, I add another control to the page in Click
event of the button and populate the three dropdowns. The text boxes
are to be populated by the user.

All ok so far, but when I click the button again, since it is a
postback, I do not rebind the data to the dropdowns and their options
disappear, although the seven text boxes maintain their state.

Can anyone explain why this might be?

Ta, Mark

Aug 16 '06 #7
In this case, you'll want to make sure viewstate is disabled for them.
Otherwise you'll get the double hit of storing everything in the viewstate
and rebinding.

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
<ma**********@g mail.comwrote in message
news:11******** **************@ 75g2000cwc.goog legroups.com...
Ok, thanks a lot for taking the time Karl.

I have found that by binding the data to the drop downs, even when
posting back, the selected values of the drop downs is maintained,
which is exactly the behaviour I want.

Thanks for your help!

Mark

Karl Seguin [MVP] wrote:
>Mark:
Textboxes are very unique in their ability to retain their state. They'll
retain their state via Request.Form, rather than the ViewState like most
(all?) other controls - that's because they are single valued. Don't be
thrown off by this unique behaviour :)

ReloadTheContr ol() was just a stub function...all it would do is
something
like:

Blah.Controls. Add(Page.LoadCo ntrol("adsadsa. ascx"))..
if you have multiple controls, you'll need to store a more complicated
object in the viewstate...suc h as an arraylist of strings...
public void AddDynamicContr ol(string path)
{
ArrayList controlsToReloa d = (ArrayList)View State["dynamicControl s"];
if (controlsToRelo ad == null)
{
controlsToReloa d = new ArrayList();
ViewState.Add(" dynamicControls ", controlsToReloa d);
}
controlsToReloa d .Add(Path);
}

so whever you dynamically add a new control, you call AddDynamicContr ol

LoadControl("w hatever.ascx");
AddDynamicCont rol("whatever.a scx");
Then on PostBack, you can reload all the controls:

public vod ReloadDynamicCo ntrols()
{
ArrayList controslToReloa d = (ArrayList)View State["dynamicControl s"];
if (controslToRelo ad ! = null)
{
foreach (string path in controslToReloa d)
{
Page.LoadContro l(path);
}
}
}

Anyways, all of this is just some code off hte top of my head, you'll
likely
need to fx it up a bit/a lot :)

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
<ma**********@ gmail.comwrote in message
news:11******* *************** @75g2000cwc.goo glegroups.com.. .
Karl

Would you mind explaining this in a little more detail? I'm reluctant
to use a third-party component because I want to know what the problem
is for myself so I can increase my understanding.

Why is it that some of the controls in my user control (text boxes)
maintain their state, yet others (drop downs) do not?

And I'm not entirely convinced I understand the function of the
ReloadTheContro l() method in your example, or how to distinguish one
control from another using ViewState.Add(" ControlLoaded", true), since
there many be many of these user controls on the page.

Thanks, Mark

Karl Seguin [MVP] wrote:
Just to add to that, you can use Denis Bauer's
DynamicControl sPlaceholder
to
hepl you do this (free):
http://www.denisbauer.com/ASPNETCont...aceholder.aspx

or you can roll the logic urself, which isn't too hard. Normally
people
store the this value in the ViewState:

LoadControl("a sdsa.ascx");
ViewState.Add( "ControlLoaded" , true);

and then check on postback:

if (Page.IsPostBac k AND (bool)ViewState["ControlLoa ded"])
{
ReloadTheContro l();
}

if you reloadthecontro l during or before onLoad, state should be
maintained.

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Kevin Spencer" <uc*@ftc.govwro te in message
news:ui******* *******@TK2MSFT NGP03.phx.gbl.. .
Since the Control is dynamically added, it is not referenced in the
class
definition. Since the Page class must be rebuilt from scratch with
each
PostBack, the dynamically-created Control must be manually restored
with
each PostBack.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Orange you bland I stopped splaying bananas?
<ma**********@g mail.comwrote in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
I've asked this question before, but still haven't solved it, so am
asking again.

I am programmaticall y adding a user control to the page in response
to
a button click. The user control consists of three dropdowns and
seven
text boxes.

When the button is clicked, I add another control to the page in
Click
event of the button and populate the three dropdowns. The text
boxes
are to be populated by the user.

All ok so far, but when I click the button again, since it is a
postback, I do not rebind the data to the dropdowns and their
options
disappear, although the seven text boxes maintain their state.

Can anyone explain why this might be?

Ta, Mark


Aug 16 '06 #8
Good point! Never thought of that. Perhaps that's why the pages are
often approaching 1MB in size. I'm expecting a visit from the network
administrator sometime soon...

Karl Seguin [MVP] wrote:
In this case, you'll want to make sure viewstate is disabled for them.
Otherwise you'll get the double hit of storing everything in the viewstate
and rebinding.

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
<ma**********@g mail.comwrote in message
news:11******** **************@ 75g2000cwc.goog legroups.com...
Ok, thanks a lot for taking the time Karl.

I have found that by binding the data to the drop downs, even when
posting back, the selected values of the drop downs is maintained,
which is exactly the behaviour I want.

Thanks for your help!

Mark

Karl Seguin [MVP] wrote:
Mark:
Textboxes are very unique in their ability to retain their state. They'll
retain their state via Request.Form, rather than the ViewState like most
(all?) other controls - that's because they are single valued. Don't be
thrown off by this unique behaviour :)

ReloadTheContro l() was just a stub function...all it would do is
something
like:

Blah.Controls.A dd(Page.LoadCon trol("adsadsa.a scx"))..
if you have multiple controls, you'll need to store a more complicated
object in the viewstate...suc h as an arraylist of strings...
public void AddDynamicContr ol(string path)
{
ArrayList controlsToReloa d = (ArrayList)View State["dynamicControl s"];
if (controlsToRelo ad == null)
{
controlsToReloa d = new ArrayList();
ViewState.Add(" dynamicControls ", controlsToReloa d);
}
controlsToReloa d .Add(Path);
}

so whever you dynamically add a new control, you call AddDynamicContr ol

LoadControl("wh atever.ascx");
AddDynamicContr ol("whatever.as cx");
Then on PostBack, you can reload all the controls:

public vod ReloadDynamicCo ntrols()
{
ArrayList controslToReloa d = (ArrayList)View State["dynamicControl s"];
if (controslToRelo ad ! = null)
{
foreach (string path in controslToReloa d)
{
Page.LoadContro l(path);
}
}
}

Anyways, all of this is just some code off hte top of my head, you'll
likely
need to fx it up a bit/a lot :)

Karl

--
http://www.openmymind.net/
http://www.fuelindustries.com/
<ma**********@g mail.comwrote in message
news:11******** **************@ 75g2000cwc.goog legroups.com...
Karl

Would you mind explaining this in a little more detail? I'm reluctant
to use a third-party component because I want to know what the problem
is for myself so I can increase my understanding.

Why is it that some of the controls in my user control (text boxes)
maintain their state, yet others (drop downs) do not?

And I'm not entirely convinced I understand the function of the
ReloadTheContro l() method in your example, or how to distinguish one
control from another using ViewState.Add(" ControlLoaded", true), since
there many be many of these user controls on the page.

Thanks, Mark

Karl Seguin [MVP] wrote:
Just to add to that, you can use Denis Bauer's
DynamicControls Placeholder
to
hepl you do this (free):
http://www.denisbauer.com/ASPNETCont...aceholder.aspx

or you can roll the logic urself, which isn't too hard. Normally
people
store the this value in the ViewState:

LoadControl("as dsa.ascx");
ViewState.Add(" ControlLoaded", true);

and then check on postback:

if (Page.IsPostBac k AND (bool)ViewState["ControlLoa ded"])
{
ReloadTheContro l();
}

if you reloadthecontro l during or before onLoad, state should be
maintained.

Karl

--
http://www.openmymind.net/
http://www.codebetter.com/
"Kevin Spencer" <uc*@ftc.govwro te in message
news:ui******** ******@TK2MSFTN GP03.phx.gbl...
Since the Control is dynamically added, it is not referenced in the
class
definition. Since the Page class must be rebuilt from scratch with
each
PostBack, the dynamically-created Control must be manually restored
with
each PostBack.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Surgery

Orange you bland I stopped splaying bananas?
<ma**********@g mail.comwrote in message
news:11******** *************@b 28g2000cwb.goog legroups.com...
I've asked this question before, but still haven't solved it, so am
asking again.

I am programmaticall y adding a user control to the page in response
to
a button click. The user control consists of three dropdowns and
seven
text boxes.

When the button is clicked, I add another control to the page in
Click
event of the button and populate the three dropdowns. The text
boxes
are to be populated by the user.

All ok so far, but when I click the button again, since it is a
postback, I do not rebind the data to the dropdowns and their
options
disappear, although the seven text boxes maintain their state.

Can anyone explain why this might be?

Ta, Mark


Aug 17 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
7932
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the header of the datagrid in the "ItemDataBound" method of the grid. However, once, they are added in the grid, i seem to lose the event handler for the same control. Is there anyone who has tried this before and knows why this is hapenning ??
2
3485
by: Devin Fensterheim | last post by:
Does anyone know of an issue with a control's viewstate not persisting when dynamically adding custom controls to a web form using AddAt? If a control is added to an HTML form directly using the HtmlForm's AddAt method (per the below code segment), then LoadViewState is never fired for the control, even if SaveViewState, which is fired, saves to the control's ViewState. However, if Add is used instead of AddAt, LoadViewState is called...
4
1415
by: RN | last post by:
In certain situations, I add a datagrid and a button beneath it. All programmatically added in the "code behind". I add them to a cell with cell.add(datagrid) and cell.add(button). Take the button for example. Usually, if the button were there statically, in the ASPX "html" code, I would simply put some code I want to run in the button's click routine in my code-behind. But it seems I can't have a button click routine that will...
1
1336
by: Josh | last post by:
I am trying to move some of my more common controls into user controls. However, I seem to have problems maintaining state of databound controls that are contained within user controls. On postback the controls still display correctly. However, trying to access the controls programatically gets me into their default (unbound) values. I feel like I am missing something basic about creating user controls. Any help is appreciated. Below...
2
1470
by: Nomen Nescio | last post by:
Hi I've been trying to add a control dynamically to my page in order to pass a value to some client side script. I've solved that problem with a different approach now but I'd still like to know what was going on with my first method. On first load the following example will add MyTextBox to the placeholder and some JavaScript which knows the field ID to look for can read its content. So far so good. However, after a PostBack I'd like
4
5055
by: | last post by:
I have a "form field highlight" javascript that I've added to some of my ASP.NET forms using the following syntax: body.Attributes.Add("onClick", "highlight(event);"); body.Attributes.Add("onKeyUp", "highlight(event);"); Some of my forms have a great many text box controls that I want to highlight.. I would much rather that ASP.NET do the work of looping through all text boxes and applying these two attributes.
0
1320
by: mark.norgate | last post by:
Hi I'm having a problem in adding controls to a page programmatically in response to a button click. Composite user controls added programmatically in the CreateChildControls() method work fine; they maintain their state as expected. Cool and groovy. However, since CreateChildControls() is called before the method that responds to the button click, say AddControl_Click(), for some reason, this control does not maintain its
12
2460
by: Michael Lang | last post by:
I'm adding checkbox controls to a panel in a post back, I then have a second post back in which I attempt to process the checkbox controls however they seem to have disappeared off the panel. The following code demonstrates what I'm trying to do. Can anyone explain why there is no checkbox control on the panel when btnTwo is clicked? ...
2
15071
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have been able to find the cause of the problem, and will describe it here first textually and then through a code example. The purpose of what I am trying to do is to create a postback-free web application through the use of ASP.net AJAX UpdatePanels...
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9957
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9835
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5276
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.