J
James Identity
I have an aspx page that loads an ascx user control.
This is what happens:
1. As the aspx page loads it then loads the ascx usercontrol.
2. After loading the user control the aspx page calls a method in the user
control
Control c1 = LoadControl("UserControl1.ascx");
PlaceHolderControl.Controls.Add(c1);
UserControl1 myControl = (UserControl1) c1;
myControl.Id = "myControl";
myControl.SetDataRecord(myRecord);//Record that contains data needed by the
control.
When the control first loads it is ok because the Load method of the user
control is
called and then the SetDataRecord(MyRecord myRecord) is called.
When the page is posted back there is a problem.
The SetDataRecord is called first and then the Load method of the user
control is called.
This is causing a problem.
I need the control to load in a consistent way so that I can program it.
I need the control to load first every time and then I need to set the data
record and then there are more functions in the PreRender event.
On postback, the difference is that there is ViewState data.
How does the method get called on the control after it loads
and how does the method get called before it loads. How do I make this
consistant.
Also.
What determines when the user control life cycle evens are called and how
does that synchronize to the life cycle events to the aspx page that loads
the control ?
Thanks for any advice.
James
This is what happens:
1. As the aspx page loads it then loads the ascx usercontrol.
2. After loading the user control the aspx page calls a method in the user
control
Control c1 = LoadControl("UserControl1.ascx");
PlaceHolderControl.Controls.Add(c1);
UserControl1 myControl = (UserControl1) c1;
myControl.Id = "myControl";
myControl.SetDataRecord(myRecord);//Record that contains data needed by the
control.
When the control first loads it is ok because the Load method of the user
control is
called and then the SetDataRecord(MyRecord myRecord) is called.
When the page is posted back there is a problem.
The SetDataRecord is called first and then the Load method of the user
control is called.
This is causing a problem.
I need the control to load in a consistent way so that I can program it.
I need the control to load first every time and then I need to set the data
record and then there are more functions in the PreRender event.
On postback, the difference is that there is ViewState data.
How does the method get called on the control after it loads
and how does the method get called before it loads. How do I make this
consistant.
Also.
What determines when the user control life cycle evens are called and how
does that synchronize to the life cycle events to the aspx page that loads
the control ?
Thanks for any advice.
James