.aspx文件源码:
<table class="style1" align="center">
<tr>
<td class="style3" align="right">
用户名:</td>
<td>
<asp:TextBox ID="tbusername" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style3" align="right">
密 码:</td>
<td>
<asp:TextBox ID="tbpwd" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style2" colspan="2" align="center">
<asp:Button ID="btnLogin" runat="server" Text="登陆" οnclick="btnLogin_Click"
style="width: 40px" />
</td>
</tr>
<tr>
<td class="style3" colspan="2">
作者:乘风直上<br />
网易博客:<a href="http://shuikanshui.blog.163.com">http://shuikanshui.blog.163.com</a><br />
csdn博客:<a href="http://blog.csdn.net/shuikanshui">http://blog.csdn.net/shuikanshui</a></td>
</tr>
</table>
.cs文件主要代码
if (tbusername.Text == "乘风直上" && tbpwd.Text == "shuikanshui")
{
string userstr = Convert.ToString(Cache["shuikanshui"]);
if (userstr == string.Empty)
{
Cache["shuikanshui"] = "乘风直上";
Response.Write("你好,乘风直上,你登陆成功!");
tbusername.Text = "";
tbpwd.Text = "";
}
else
{
Response.Write("你好,你已经登陆!");
tbusername.Text = "";
tbpwd.Text = "";
return;
}
}
else { Response.Write("用户名或密码错误!"); }
运行效果图:
添加信息
登陆成功
再次登陆