User Controls In Wizard

L

Larry R

I am having a problem with saving some state between user controls.I
know that it is a event/lifecyclye thing, but can;t quite find the
right event.

Here is the setup:
I have a Customer BO that is stored in session.
There is a wizard that gets the id, loads the Customer, allows
changes, then saves. Simple, right?

Since the steps in the final project are quite dynamic, I extracted
out the individual steps (GetID, UpdateData) into user controls
(ascx). The wizard, on Wizard1_ActiveStepChanged, loads the
approproriate control into a placeholder.

The GetId is a simple textbox, when saved calls a static method on the
CustomerBO to load and be saved in session state.

The UpdateData binds two text boxes to the Name & Address. When
Updated, the Session[customerKey] BO is updated.
----
If I leave the controls defined in the ASPX page, it is OK. But if I
load the control into a placeholder, the control loads, but I never
get the textChanged event:
void Wizard1_ActiveStepChanged(object sender, EventArgs e)
{
int stepIndex = Wizard1.ActiveStepIndex;
switch (stepIndex)
{
case 0:
Session.Remove("Customer_1");
break;
case 1:
GetId control = (GetId)LoadControl("GetId.ascx");
this.GetIdHolder.Controls.Add(control);
break;

====
user Control:
protected override void OnInit(EventArgs e)
{
PopulateValues();
base.OnInit(e);
}

private void PopulateValues()
{
if (txtCustomerId.Text != string.Empty)
this.Customer =
Customer.GetCustomerFromId(Convert.ToInt32(txtCustomerId.Text));
}
protected void txtCustomerId_TextChanged(object sender, EventArgs
e)
{
if (txtCustomerId.Text != string.Empty)
this.Customer =
Customer.GetCustomerFromId(Convert.ToInt32(txtCustomerId.Text));
}
==============
SO, if I have the control above defined in the Wizard statically, it
is ok, But if I load it dynamically, the txtCustomerId_TextChanged
never gets called.

Can anyone tell me which event should be overrided to make this
happen? Or point me to the right place? I have looked at dozens of
articles and everything comes close, but not quite.

Thanks.
Larry
 

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

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,709
Latest member
AustinMudi

Latest Threads

Top