In your code-behind file, add the following in the Page.Load method.
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack) {
lb1.CssClass = "On";
lb2.CssClass = "Off";
lb3.CssClass = "Off";
lb4.CssClass = "Off";
pnl1.Style.Add("display", "inline");
pnl2.Style.Add("display", "none");
pnl3.Style.Add("display", "none");
pnl4.Style.Add("display", "none");
}
}
This will show the first step when the page loads and all of the others will be hidden. Double-click each link button and add the following code to their click event handlers:
private void lb1_Click(object sender, System.EventArgs e)
{
lb1.CssClass = "On";
lb2.CssClass = "Off";
lb3.CssClass = "Off";
lb4.CssClass = "Off";
pnl1.Style.Add("display", "inline");
pnl2.Style.Add("display", "none");
pnl3.Style.Add("display", "none");
pnl4.Style.Add("display", "none");
}
private void lb2_Click(object sender, System.EventArgs e)
{
lb1.CssClass = "Off";
lb2.CssClass = "On";
lb3.CssClass = "Off";
lb4.CssClass = "Off";
pnl1.Style.Add("display", "none");
pnl2.Style.Add("display", "inline");
pnl3.Style.Add("display", "none");
pnl4.Style.Add("display", "none");
}
private void lb3_Click(object sender, System.EventArgs e)
{
lb1.CssClass = "Off";
lb2.CssClass = "Off";
lb3.CssClass = "On";
lb4.CssClass = "Off";
pnl1.Style.Add("display", "none");
pnl2.Style.Add("display", "none");
pnl3.Style.Add("display", "inline");
pnl4.Style.Add("display", "none");
}</font>
<font face="Arial" size="2"> private void lb4_Click(object sender, System.EventArgs e)
{
lb1.CssClass = "Off";
lb2.CssClass = "Off";
lb3.CssClass = "Off";
lb4.CssClass = "On";
pnl1.Style.Add("display", "none");
pnl2.Style.Add("display", "none");
pnl3.Style.Add("display", "none");
pnl4.Style.Add("display", "inline");
}
Now, you can build your project and view your webform in your browser by going to http://localhost/Wizard/WebForm1.aspx.
It should appear like this:
You have now created a simulated wizard control in ASP.NET 1.x. Enjoy!