Welcome Guest Search | Active Topics | Members | Log In | Register

User Controls In Wizard Options · View
Larry R
Posted: Sunday, October 07, 2007 3:45:37 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 07/10/2007 15:45:37
Date: Sun, 07 Oct 2007 15:45:37 -0000

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

Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.1 (NET v2.0) - 9/10/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.032 seconds.