Wizard Next Button Error


J

JMehta

I have a web page with a master page and a contents page. On the contents
page I have a wizard as defined below:
<asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="1"
DisplayCancelButton="True" Height="85px" Width="647px"
OnNextButtonClick="NextButtonClick_SkipStep"
OnActiveStepChanged="OnActiveStepChanged_SaveCurrPrevIndex"

CancelDestinationPageUrl="~/SystemAdminOnly/CMTables/OutcallSchedule/ManageOutcallSchedule-LoadNumbers.aspx"
DisplaySideBar="False">
<StepStyle HorizontalAlign="Left" VerticalAlign="Top" />
<StartNavigationTemplate>
<asp:Button ID="StartNextButton" runat="server"
CommandName="MoveNext" Visible="false"
Text="Next" />
<asp:Button ID="CancelButton" runat="server"
CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</StartNavigationTemplate>
<WizardSteps>
<asp:WizardStep runat="server" StepType="Start" title="Step 1">
<code style="font-family: Verdana; font-size: 10pt; color:
navy; ">Step1...</code>
</asp:WizardStep>
<asp:WizardStep runat="server" StepType="Start" title="Step 2">
<code style="font-family: Verdana; font-size: 10pt; color: navy;
">Step2...</code>
</asp:WizardStep>
</asp:WizardSteps>
<SideBarStyle VerticalAlign="Top" />
<StepNavigationTemplate>
<asp:Button ID="StepPreviousButton" runat="server"
CausesValidation="False"
CommandName="MovePrevious" Text="Previous" />
<asp:Button ID="StepNextButton" runat="server"
CommandName="MoveNext"
Text="Next" Visible="false"/>
<asp:Button ID="CancelButton" runat="server"
CausesValidation="False"
CommandName="Cancel" Text="Cancel" />
</StepNavigationTemplate>
</asp:Wizard>

I also have a script defined to set display of the StepNextButton in the
StepNavigationTemplate.
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
TextBox3.Text = "0";
TextBox4.Text = "0";
}
}

protected void OnActiveStepChanged_SaveCurrPrevIndex(object sender,
EventArgs e)
{
if (IsPostBack)
//NOT first time
{
TextBox3.Text = TextBox4.Text;
TextBox4.Text = Wizard1.ActiveStepIndex.ToString();
}

if (Wizard1.ActiveStepIndex == 1)
{
Button btn =
(Button)Wizard1.FindControl("StepNavigationTemplateContainerID$StepNextButton");
btn.Visible = true;
}

if (Wizard1.ActiveStepIndex >1)
{
Button btn =
(Button)Wizard1.FindControl("StepNavigationTemplateContainerID$StepNextButton");
btn.Visible = false;
}
}

When this page is activated, I get the following error:
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.

Source Error:
Line 53: {
Line 54: Button btn =
(Button)Wizard1.FindControl("StepNavigationTemplateContainerID$StepNextButton");
Line 55: btn.Visible = true;
Line 56: }
Line 57:

Can you tell me why and what I need to change?
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top