最简单的没有涉及数据库的登录

刚刚开始接触asp.net,处女作。一个没有涉及数据库最简单的登录界面,放在这里记录自己学习中的成长吧。。。

 

 

这是前台

<head id="Head1" runat="server">

    <title>登录</title>

 

</head>

<body>

    <form id="form1" runat="server">

        <div  align="center">

 

                   <asp:Label ID="Label1" runat="server" Text="登录" Font-Size="24px" style="height: 100px; width: 246px" ></asp:Label><br/>

            <asp:Panel ID="Panel1" runat="server" Height="126px" Width="372px" BorderColor="Green" 

                       BorderStyle="Ridge">

 

 

                <table cellpadding="0" border="0" cellspacing="0"  style="height: 100px; width: 246px">

                   <tr>

                        <td >姓名:</td>

                        <td >

 

                            <asp:DropDownList ID="DropDownList1" runat="server"  Height="16px" 

                                Width="129px" >

                                <asp:ListItem Value="jack"></asp:ListItem>

                                <asp:ListItem Value="lily"></asp:ListItem>

                            </asp:DropDownList >

 

                        </td>

                   </tr> 

                   <tr>

                        <td >密码:</td>

                        <td >

                            <input type="text" name ="ps" />

 

                            </td>

                   </tr>   

 

                    </table>

                 </asp:Panel>

                  <input  type="submit"  value="submit"  name="su" 

                       style="height: 25px; width: 52px" /><asp:Label ID="Label2" runat="server" 

                       Text="Label" ForeColor="Red" ></asp:Label>

 

 

 

 

 

 

       </div>

    </form>

</body>

 

后台的:

 

protected void Page_Load(object sender, EventArgs e)

        {

 

            string sname = Request["DropDownList1"];

            string sps = Request["ps"];

            if (!Page.IsPostBack)

            {

                this.Label2.Text = "";

            }

            else

            {

                if (this.DropDownList1.Text == "jack" && sps == "123")

                {

                    this.Label2.Text = "成功";

                }

                else if (this.DropDownList1.Text == "lily" && sps == "456")

                {

                    this.Label2.Text = "成功";

                }

                else

                {

                    this.Label2.Text = "失败";

                }

            }

        }

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值