Mega Code Archive

 
Categories / ASP.Net Tutorial / ASP Net Controls
 

Wizard and its steps (C#)

File: Default.aspx <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="WizardGreetingCardMaker" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">     <title>Greeting Card Wizard</title> </head> <body>     <form id="form1" runat="server">     <div>         <asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0" BackColor="LemonChiffon" BorderStyle="Groove" BorderWidth="2px" CellPadding="10" OnFinishButtonClick="Wizard1_FinishButtonClick" Width="456px">             <WizardSteps>                 <asp:WizardStep runat="server" Title="Step 1 - Colors">                 Choose a foreground (text) color:<br  />                 <asp:DropDownList ID="lstForeColor" runat="server" Width="194px">                 </asp:DropDownList><br/>                 <br  />                 Choose a background color:<br  />                 <asp:DropDownList ID="lstBackColor" runat="server" Width="194px">                 </asp:DropDownList>                                                            </asp:WizardStep>                 <asp:WizardStep runat="server" Title="Step 2 - Background">                                      Choose a border style:<br  />                 <asp:RadioButtonList ID="lstBorder" runat="server"                      Height="59px" RepeatColumns="2" Width="177px">                 </asp:RadioButtonList><br  />                 <br  />                 <asp:CheckBox ID="chkPicture" runat="server"                      Text="Add the Default Picture"  />                                                  </asp:WizardStep>                 <asp:WizardStep runat="server" Title="Step 3 - Text">                                  Choose a font name:<br  />                 <asp:DropDownList ID="lstFontName" runat="server"  Width="194px">                 </asp:DropDownList><br  />                 <br  />                 Specify a font size:<br  />                 <asp:TextBox ID="txtFontSize" runat="server" ></asp:TextBox><br  />                 <br  />                 Enter the greeting text below:<br  />                 <asp:TextBox ID="txtGreeting" runat="server"                      TextMode="MultiLine" Width="240px" ></asp:TextBox>                                  </asp:WizardStep>                 <asp:WizardStep runat="server" StepType="Complete" Title="Greeting Card">                 <asp:Panel ID="pnlCard" runat="server" Height="445px" HorizontalAlign="Center" Style="z-index: 101;" Width="339px">             <br />             &nbsp;             <asp:Label ID="lblGreeting" runat="server" Height="150px" Width="272px"></asp:Label>             <asp:Image ID="imgDefault" runat="server" Height="160px" Visible="False" Width="212px" /></asp:Panel>                 </asp:WizardStep>             </WizardSteps>         </asp:Wizard>          </div>     </form> </body> </html> File: Default.aspx.cs using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Drawing; using System.ComponentModel; public partial class WizardGreetingCardMaker : System.Web.UI.Page {     protected void Page_Load(object sender, EventArgs e)     {         if (!Page.IsPostBack)         {             string[] colorArray = Enum.GetNames(typeof(System.Drawing.KnownColor));             lstBackColor.DataSource = colorArray;             lstBackColor.DataBind();             lstForeColor.DataSource = colorArray;             lstForeColor.DataBind();             lstForeColor.SelectedIndex = 34;             lstBackColor.SelectedIndex = 163;             System.Drawing.Text.InstalledFontCollection fonts;             fonts = new System.Drawing.Text.InstalledFontCollection();             foreach (FontFamily family in fonts.Families)             {                 lstFontName.Items.Add(family.Name);             }             string[] borderStyleArray = Enum.GetNames(typeof(BorderStyle));             lstBorder.DataSource = borderStyleArray;             lstBorder.DataBind();             lstBorder.SelectedIndex = 0;             imgDefault.ImageUrl = "http://www.rntsoft.com/style/logo.png";         }     }     protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)     {         pnlCard.BackColor = Color.FromName(lstBackColor.SelectedItem.Text);         lblGreeting.ForeColor = Color.FromName(lstForeColor.SelectedItem.Text);         lblGreeting.Font.Name = lstFontName.SelectedItem.Text;         try         {             if (Int32.Parse(txtFontSize.Text) > 0)             {                 lblGreeting.Font.Size = FontUnit.Point(Int32.Parse(txtFontSize.Text));             }             if (Int32.Parse(txtFontSize.Text) > 0)             {                 lblGreeting.Font.Size =                     FontUnit.Point(Int32.Parse(txtFontSize.Text));             }         }         catch         {         }         TypeConverter cnvrt = TypeDescriptor.GetConverter(typeof(BorderStyle));         pnlCard.BorderStyle = (BorderStyle)cnvrt.ConvertFromString(lstBorder.SelectedItem.Text);         if (chkPicture.Checked == true)         {             imgDefault.Visible = true;         }         else         {             imgDefault.Visible = false;         }         lblGreeting.Text = txtGreeting.Text;     } }