刚刚开始接触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 = "失败";
}
}
}