当前位置:网站首页>ASP using panel to realize simple registration page

ASP using panel to realize simple registration page

2022-06-29 21:58:00 Eighty eight old

newly build web forms Panel.aspx
Drag in control Panel It's a container , Controls can be placed in containers
 Please add a picture description
 Please add a picture description here aspx Code :( The design is as follows )


```bash
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Panel.aspx.cs" Inherits="Chap2_Panel" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Panel ID="pnlStep1" runat="server">
                 First step : enter one user name 
             
                <br />
                 user name :<asp:TextBox ID="txtUser" runat="server"></asp:TextBox>
                <br />
                <asp:Button ID="btnStep1" runat="server" Text=" next step " />
            </asp:Panel>
        </div>
    </form>
</body>
</html>

 The same can be , Add a second 、 Three panels 



```bash
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Panel.aspx.cs" Inherits="Chap2_Panel" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Panel ID="pnlStep1" runat="server">
                 First step : enter one user name 
             
                <br />
                 user name :<asp:TextBox ID="txtUser" runat="server"></asp:TextBox>
                <br />
                <asp:Button ID="btnStep1" runat="server" Text=" next step " />
            </asp:Panel>
            <asp:Panel ID="pnlStep2" runat="server">
                 The second step : Enter user information <br />  full name :<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                <br />
                 Telephone :<asp:TextBox ID="txtTelephone" runat="server"></asp:TextBox>
                <br />
                <asp:Button ID="btnStep2" runat="server" Text=" next step " />

            </asp:Panel>
            <asp:Panel ID="pnlStep3" runat="server">
                 The third step : Please confirm your input information <br /> 
                <asp:Label ID="lb1Msg" runat="server" Text="Label"></asp:Label>
                <br />
                <asp:Button ID="btnStep3" runat="server" Text=" confirm " />
            </asp:Panel>

        </div>
    </form>
</body>
</html>

Go to background code aspx.cs
Set the page to load for the first time pnlStep1 so

protected void Page_Load(object sender, EventArgs e)
    {
    
        if(!IsPostBack)
        {
    
            pnlStep1.Visible = true;
            pnlStep2.Visible = false;// invisible 
            pnlStep3.Visible = false;
        }
    }

Double click the first button , Set up events

protected void btnStep1_Click(object sender, EventArgs e)
    {
    
        pnlStep1.Visible = false;
        pnlStep2.Visible = true;
        pnlStep3.Visible = false;
    }

Double click the second button , Set up events

protected void btnStep2_Click(object sender, EventArgs e)
    {
    
        pnlStep1.Visible = false;
        pnlStep2.Visible = false;
        pnlStep3.Visible = true;
        lb1Msg.Text = " user name :" + txtUser.Text + "<br/> full name :" + txtName.Text + "<br/> Telephone :" + txtTelephone.Text;// Output user information 
    }

Double click the third button , Set up events

protected void btnStep3_Click(object sender, EventArgs e)
    {
    
        // Save user information to the database 
    }

aspx Complete code

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Panel.aspx.cs" Inherits="Chap2_Panel" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Panel ID="pnlStep1" runat="server">
                 First step : enter one user name 
             
                <br />
                 user name :<asp:TextBox ID="txtUser" runat="server"></asp:TextBox>
                <br />
                <asp:Button ID="btnStep1" runat="server" Text=" next step " OnClick="btnStep1_Click" />
            </asp:Panel>
            <asp:Panel ID="pnlStep2" runat="server">
                 The second step : Enter user information <br />  full name :<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                <br />
                 Telephone :<asp:TextBox ID="txtTelephone" runat="server"></asp:TextBox>
                <br />
                <asp:Button ID="btnStep2" runat="server" Text=" next step " OnClick="btnStep2_Click" />

            </asp:Panel>
            <asp:Panel ID="pnlStep3" runat="server">
                 The third step : Please confirm your input information <br /> 
                <asp:Label ID="lb1Msg" runat="server" Text="Label"></asp:Label>
                <br />
                <asp:Button ID="btnStep3" runat="server" Text=" confirm " OnClick="btnStep3_Click" />
            </asp:Panel>

        </div>
    </form>
</body>
</html>

aspx.cs Complete code

using System;

public partial class Chap2_Panel : System.Web.UI.Page
{
    
    protected void Page_Load(object sender, EventArgs e)
    {
    
        if(!IsPostBack)
        {
    
            pnlStep1.Visible = true;
            pnlStep2.Visible = false;
            pnlStep3.Visible = false;
        }
    }


    protected void btnStep1_Click(object sender, EventArgs e)
    {
    
        pnlStep1.Visible = false;
        pnlStep2.Visible = true;
        pnlStep3.Visible = false;
    }

    protected void btnStep2_Click(object sender, EventArgs e)
    {
    
        pnlStep1.Visible = false;
        pnlStep2.Visible = false;
        pnlStep3.Visible = true;
        lb1Msg.Text = " user name :" + txtUser.Text + "<br/> full name :" + txtName.Text + "<br/> Telephone :" + txtTelephone.Text;// Output user information 
    }

    protected void btnStep3_Click(object sender, EventArgs e)
    {
    
        // Save user information to the database 
    }
}

 Please add a picture description

原网站

版权声明
本文为[Eighty eight old]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/180/202206292125086712.html

随机推荐