J
Jason Dunbar
Hi folks,
I have a scenario where I need to create multiple unique instances of
a Web User Control and add these controls as children to a PlaceHolder
Server Control. Here is my code so far:
private void newJourneyLeg()
{
// generate the index number based on the
current number of Dictionary Entries
int legIndex = arrLegControls.Count + 1;
// - trip leg controls must be created 'on the
fly' and so each one must take on a unique name
arrLegControls.Add(legIndex,
LoadControl("JourneyLeg.ascx"));
journeyLegs.Controls.Add((JourneyLeg)arrLegControls[legIndex]);
Trace.Warn("Leg Index Number",
legIndex.ToString());
}
Where 'arrLegControls' has been instantiated as a Hashtable.
'journeyLegs' is the ID/name of my PlaceHolder Server Control.
This method is called as part of an event handler. The event handler
is fired when a radio button is clicked (though this will eventually
be triggered by a 'new' button to create a new journeyLeg).
The Event Handler has been tied to three Radio Buttons.
When a Radio button is first clicked, the control is created fine.
When another of the radio buttons is clicked, no other controls are
created and added.
When the same Radio Button is clicked twice, the control appears the
first time, then disappears with the second click.
Any help on this would be greatly appreciated.
Thank you.
Kind Regards,
Jason
I have a scenario where I need to create multiple unique instances of
a Web User Control and add these controls as children to a PlaceHolder
Server Control. Here is my code so far:
private void newJourneyLeg()
{
// generate the index number based on the
current number of Dictionary Entries
int legIndex = arrLegControls.Count + 1;
// - trip leg controls must be created 'on the
fly' and so each one must take on a unique name
arrLegControls.Add(legIndex,
LoadControl("JourneyLeg.ascx"));
journeyLegs.Controls.Add((JourneyLeg)arrLegControls[legIndex]);
Trace.Warn("Leg Index Number",
legIndex.ToString());
}
Where 'arrLegControls' has been instantiated as a Hashtable.
'journeyLegs' is the ID/name of my PlaceHolder Server Control.
This method is called as part of an event handler. The event handler
is fired when a radio button is clicked (though this will eventually
be triggered by a 'new' button to create a new journeyLeg).
The Event Handler has been tied to three Radio Buttons.
When a Radio button is first clicked, the control is created fine.
When another of the radio buttons is clicked, no other controls are
created and added.
When the same Radio Button is clicked twice, the control appears the
first time, then disappears with the second click.
Any help on this would be greatly appreciated.
Thank you.
Kind Regards,
Jason