Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wizard containing User control

Status
Not open for further replies.

kalkumar

Programmer
Jul 7, 2006
40
US
Hi,
I have defined the User control which containg one label and textbox.
<asp:Label id=”xx” …>
<asp:textbox id=”name” runat=”server”..>
In the user control class I am defining like this:
Class us: System.Web.UI.UserControl
{
Public string setname
{
Get
{
Return name.text;
}
Set
{
Name.text=value;
}
}
Page_load()
{
}
I am using that user control in another aspx page. In which I placed the the above User control in a Wizard control.
<asp:wizard ..>
<tt.name id=”ci”> declaring usercontrol inside wizard.
</asp:wizrd>
From this aspx I am trying to set the value for the name textbox which is in User control when the Wizard Finish button is clicked.
Like this:
protected void Wizard2_FinishButtonClick(object sender, WizardNavigationEventArgs e)
{

ci.setname = "hh";
}
But this event is not firing when I remove the User control from the Wizard this event is firing.
And when I write the Page_load of aspx page
Aspx page page_load
{
If(!isPostaback)
{
ci.setname=”kk”;
}
If I put like this in the PageLoad’s !ispostback then wizrd finish event is workng.
Withoyt setting the ci.setname in the Page_load I need to set only in the finish button click.
How to do this?

Thanks
 
you need to place the user control within a wizard step. not just the wizard
Code:
<asp:Wizard>
   <Steps>
      <asp:WizardStep>
         <uc:MyControl />
      </asp:WizardStep>
   </Steps>
</asp:Wizard>

the Wizard.FinishButtonClick event only fires on the complete button. This is the last "next" button on the last wizard step.

if you want to populate the textbox in the UC on pageload use this in the page.load event
Code:
if(!page.ispostback)
{
   ci.setname = "my name";
}
if you want to set the value when a specific step is active use this in the wizard.activeindexchanged event
Code:
ci.setname = "my name";
if you only want this to happen once I would recommend the page load event.
if you only want this to happen when moving forward in the wizard compare the current step index to the new step index
Code:
if (MyWizard.ActiveStepIndex < e.NewStepIndex)
{
   ci.setname = "my name";
}

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top