ASP.Net-基本CRUD-APP 列表展示

//UserInfoList.html

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>用户列表页面</title>
    <meta charset="utf-8" />

    <link href="css/tableStyle.css" rel="stylesheet" />
    <script src="../jquery 3.3.1/jquery-3.3.1.js"></script>
    <script>
        $(function () {
            $('.delCls').click(function () {
                if (!confirm('确定要删除该记录吗?')) {
                    return false;
                }
            });
        });
    </script>
</head>
<body>
    <a href="AddUserInfo.html">添加用户</a>
    <table>
        <tr>
            <th>ID</th>
            <th>名字</th>
            <th>密码</th>
            <th>详情</th>
            <th>删除</th>
            <th>编辑</th>
        </tr>
        $tbody
    </table>
</body>
</html>

/******************************************************************************************************/

//UserInfoList.ashx

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using WebProject.BLL;
using WebProject.Model;
using System.Text;

namespace WebProject.WebApp
{
    /// <summary>
    /// UserInfoList 的摘要说明
    /// </summary>
    public class UserInfoList : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";
            UserInfoBLL bll = new UserInfoBLL();
            List<UserInfo> list = bll.GetAllUserInfo();
            StringBuilder sb = new StringBuilder();
            foreach(UserInfo user in list)
            {
                sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td><a href='UserInfoDetail.ashx?UserId={0}'>详情</a></td><td><a href='DeleteUserInfo.ashx?UserId={0}'>删除</a></td><td><a href='EditUserInfo.ashx?UserId={0}&&UserName={1}&&UserPwd={2}'>编辑<a></td></tr>",user.UserId,user.UserName,user.UserPwd);
            }
            string filePath = context.Request.MapPath("UserInfoList.html");
            string fileContent = System.IO.File.ReadAllText(filePath);
            fileContent = fileContent.Replace("$tbody", sb.ToString());
            context.Response.Write(fileContent);         

            
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值