Properties in my code behind all go null when Wizard control's next button is clicked,

201 Views Asked by At

I have a wizard control, and I have this code

    protected void Wizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)
    {
        if (Wizard1.ActiveStepIndex == 0)
        {
            if (firstName != null && lastName != null)
            {
                Wizard1.ActiveStepIndex = 1;
            }
            else
            {
                e.Cancel = true;
            }
        }
    }

when the code gets to firstName and lastName they are both null, I have populated them in a previous method above, they are not empty until this event fires. My searching has only let me to something about causes validation, is this the culprit?

1

There are 1 best solutions below

3
On BEST ANSWER

Properties will be lost on postback unless you store them in a ViewState or Session or Database.

e.g. ViewState

  public string Firstname{

    get {

return ViewState["Firstname"] == null ?String.Empty :(string)ViewState["Firstname"];

    }
    set { ViewState["Firstname"] = value; }
}