Hi Kevin,
The sequence of execution is Page's Load event first and then user
control's Load event. That is the reason you are getting stale value in
Page's Load event.
Try using OnPreRender event of Page class to check that value.
Regards,
-Kailas Tare
-----Original Message-----
From: Kevin Warner [mailto:kevinw@a...]
Sent: Thursday, February 06, 2003 2:05 PM
To: ASPX_Professional
Subject: [aspx_professional] Custom Server Control Problem
I have an ASP.NET page that uses two custom server controls: WizardSteps
and WizardNavigation.
<MAB:WizardSteps ID=3D"MyWizardSteps" SelectedStep=3D"1"
Runat=3D"Server">
<ASP:Panel id=3D"Step1" Runat=3D"Server">
...Some stuff...
</ASP:Panel>
<ASP:Panel id=3D"Step2" Runat=3D"Server">
...Some stuff...
</ASP:Panel>
</MAB:WizardSteps>
<MAB:WizardNavigation ID=3D"MyWizardNavigation"
AssociatedWizardControl=3D"MyWizardSteps"
Runat=3D"Server"/>
The WizardSteps control simply shows or hides a step (child panel) based
on the value of its own SelectedStep property.
The WizardNavigation control displays Back and Next buttons. This
control
also handles the click events for these buttons within its own code. If
either button is clicked, this control gets a reference to the
WizardSteps
control by using the value of the AssociatedWizardControl property.
Then,
depending on which button was clicked, the code in the WizardNavigation
control actually updates the SelectedStep property of the WizardSteps
control.
OK... It works great, except...
When I attempt to access the SelectedStep property of the WizardSteps
control FROM my ASP.NET page, I get a slightly stale value. For example,
when I click the next button to go to step 2, and when I check the value
of the SelectedStep property in the Page_Load sub, the value is 1. The
appropriate step(2) displays, it is just that in the Page_Load sub, the
value is stale. I placed some Response.Write methods AFTER the location
where the WizardSteps control exists in the page to check the value of
the
SelectedStep property, and it is fine. But, it does me no good down
there.
I need to access it in the Page_Load sub.
Is it a problem when one control sets the property of another control?
Should I only set the SelectedStep property from the ASP.NET page?
I appreciate any suggestions!
Kevin