web网页设计信息登系统q前端html后端cs代码
时间: 2023-11-15 19:14:54 浏览: 48
好的,以下是一个使用 HTML 和 C# 开发的简单信息登记系统的示例代码:
HTML 页面:
```html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>信息登记系统</title>
</head>
<body>
<h1>信息登记系统</h1>
<form id="login-form">
<label>用户名:</label>
<input type="text" name="username"><br>
<label>密码:</label>
<input type="password" name="password"><br>
<button type="submit">登录</button>
</form>
<div id="message"></div>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="app.js"></script>
</body>
</html>
```
C# 后端代码:
```csharp
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
string username = Request.Form["username"];
string password = Request.Form["password"];
if (username == "admin" && password == "123456")
{
Session["username"] = username;
Response.Redirect("Index.aspx");
}
else
{
message.InnerHtml = "用户名或密码错误!";
}
}
}
}
```
以上代码实现了一个简单的登录功能,当用户在 HTML 页面中输入用户名和密码后,点击登录按钮提交表单,后端会验证用户名和密码是否正确,如果正确,则将用户名保存在 Session 中,并跳转到 Index.aspx 页面;否则,在 HTML 页面中显示错误信息。
当然,这只是一个简单的示例,实际开发中还需要考虑很多其他方面的问题,比如数据库的设计和操作、数据的增删改查等。