ASP.net code C# การใช้งาน Multi View และ Wizard

posted on 27 Oct 2009 15:54 by techinnoreview  in MITT
// ส่วน code ของ Multi view เป็นแบบทำ 3 ปุ่ม
 
 
public partial class _Default : System.Web.UI.Page 
{

    protected void Button1_Click(object sender, EventArgs e)
    {
        MultiView1.SetActiveView(View2);
        Label2.Text = Name1.Text + "<br/>";
        Label2.Text += Email1.Text + "<br/>";
        Label2.Text += Id1.Text + "<br/>";
    }
    protected void Back1_Click(object sender, EventArgs e)
    {
        MultiView1.SetActiveView(View1);
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        MultiView1.SetActiveView(View3);
        Label1.Text = Name1.Text + "<br/>";
        Label1.Text += Email1.Text + "<br/>";
        Label1.Text += Id1.Text + "<br/>";
        Label1.Text += "<br/>" + TextBox1.Text + "<br/>";
    }
 
// ส่วน หน้าเว็บ
 
  <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Multi View</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
        &nbsp;<asp:View ID="View1" runat="server">
            Please Insert Your Name, Email and ID<br />
            <br />
            Name&nbsp; :
            <asp:TextBox ID="Name1" runat="server"></asp:TextBox>
            <br />
            <br />
            E-Mail :
            <asp:TextBox ID="Email1" runat="server"></asp:TextBox>
            <br />
            <br />
            ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :&nbsp;
            <asp:TextBox ID="Id1" runat="server"></asp:TextBox>
            <br />
            <br />
            <asp:Button ID="Button1" runat="server" Text="Go to Next" OnClick="Button1_Click" />
            <br />
        </asp:View>
        <asp:View ID="View2" runat="server">
            Address<br />
            <br />
            <asp:TextBox ID="TextBox1" runat="server" Height="116px" TextMode="MultiLine" 
                Width="540px"></asp:TextBox>
            <br />
            <br />
            You Now Have<br />
            <br />
            <asp:Label ID="Label2" runat="server"></asp:Label>
            <br />
            <br />
            <br />
            <asp:Button ID="Back1" runat="server" style="margin-left: 50px" Text="Back" 
                Width="66px" OnClick="Back1_Click" />
            &nbsp;<asp:Button ID="Button2" runat="server" style="margin-left: 63px" 
                Text="Almost Finish, Please go to next" OnClick="Button2_Click"  />
            <br />
        </asp:View>
        <asp:View ID="View3" runat="server">
            <br />
            <asp:Label ID="Label1" runat="server"></asp:Label>
            <br />
        </asp:View>
    </asp:MultiView>
    </form>
</body>
</html>

 
// จะเป็นแนวนี้ครับ
 
 
 Please Insert Your Name, Email and ID

Name  :

E-Mail :

ID       : 


Address


// ส่วน code ของ wizard เป็นแบบทำ ปุ่ม finish อย่างเดียว
 
public partial class WizardView : System.Web.UI.Page
{

    protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
    {
            Label2.Text = TextBox1.Text + "<br/>";
            Label2.Text += TextBox2.Text + "<br/>";
            Label2.Text += TextBox3.Text + "<br/>";
            Label1.Text = TextBox1.Text + "<br/>";
            Label1.Text += TextBox2.Text + "<br/>";
            Label1.Text += TextBox3.Text + "<br/>";
    }

}
 
 
 // ส่วน หน้าเว็บ
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Wizard</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0" BackColor="#FFFBD6" 
        BorderColor="#FFDFAD" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" 
        Height="325px" onfinishbuttonclick="Wizard1_FinishButtonClick" Width="571px">
        <WizardSteps>
            <asp:WizardStep ID="S1" runat="server" title="Step 1">
                Name :
                <asp:TextBox ID="TextBox1" runat="server" Width="190px"></asp:TextBox>
                <br />
                <br />
                Email :
                <asp:TextBox ID="TextBox2" runat="server" style="margin-left: 38px" 
                    Width="195px"></asp:TextBox>
            </asp:WizardStep>
            <asp:WizardStep ID="S2" runat="server" title="Step 2">
                <asp:TextBox ID="TextBox3" runat="server" Height="212px" TextMode="MultiLine" 
                    Width="282px">Type Your Address</asp:TextBox>
            </asp:WizardStep>
            <asp:WizardStep ID="S3" runat="server" Title="Step 3">
                <asp:Label ID="Label1" runat="server"></asp:Label>
                <br />
                <br />
                Please Recheck Your Information.<br />
            </asp:WizardStep>
            <asp:WizardStep ID="S4" runat="server" StepType="Complete" Title="Finish">
                <asp:Label ID="Label2" runat="server"></asp:Label>
                <br />
                <br />
                <br />
                Thank You
            </asp:WizardStep>
        </WizardSteps>
        <SideBarButtonStyle ForeColor="White" />
        <NavigationButtonStyle BackColor="White" BorderColor="#CC9966" 
            BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" 
            ForeColor="#990000" />
        <SideBarStyle BackColor="#990000" Font-Size="0.9em" VerticalAlign="Top" />
        <HeaderStyle BackColor="#FFCC66" BorderColor="#FFFBD6" BorderStyle="Solid" 
            BorderWidth="2px" Font-Bold="True" Font-Size="0.9em" ForeColor="#333333" 
            HorizontalAlign="Center" />
    </asp:Wizard>
    <div>
    
    </div>
    </form>
</body>
</html>
 

 


Comment

smilebig smileopen-mounthed smileconfused smilesad smileangry smiletonguequestionembarrassedsurprised smilewinkdouble winkcry
smilebig smileopen-mounthed smileconfused smilesad smileangry smiletonguequestionembarrassedsurprised smilewinkdouble winkcry

Tweet