1. 一般删除网页数据

就是指用户在点击删除的时候,会跳转到DeleteUser.ashx一般处理程序中,并且通过get传参的方式传递一个id的参数,然后在后台处理

<a href='DeleteUser.ashx?id={0}

具体代码如下:

using CZBK.ItcastProject.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web; namespace CZBK.ItcastProject.WebApp
{
/// <summary>
/// UserInfoList 的摘要说明
/// </summary>
public class UserInfoList : IHttpHandler
{ public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/html";
BLL.UserInfoService UserInfoService = new BLL.UserInfoService();
List<UserInfo>list= UserInfoService.GetList();
StringBuilder sb = new StringBuilder();
foreach (UserInfo userInfo in list)
{ //点击删除跳转的地址
sb.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td><a href='DeleteUser.ashx?id={0}' class='deletes'>删除</a></td><td><a href='ShowDetail.ashx?uid={0}'>详细</a></td><td><a href='ShowEdit.ashx?id={0}'>编辑</a></td></tr>",userInfo.Id,userInfo.UserName,userInfo.UserPass,userInfo.Email,userInfo.RegTime);
}
//读取模板文件
string filePath = context.Request.MapPath("UserInfoList.html");
string fileCotent = File.ReadAllText(filePath);
fileCotent = fileCotent.Replace("@tbody",sb.ToString());
context.Response.Write(fileCotent);
} public bool IsReusable
{
get
{
return false;
}
}
}
}

UserInfoList.ashx

DeleteUser.ashx 相关代码展示如下

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; namespace CZBK.ItcastProject.WebApp
{
/// <summary>
/// DeleteUser 的摘要说明
/// </summary>
public class DeleteUser : IHttpHandler
{ public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
int id; // out id 就是指将值赋值给id
if (int.TryParse(context.Request.QueryString["id"], out id))
{ BLL.UserInfoService UserInfoService = new BLL.UserInfoService();
//如果删除成功
if (UserInfoService.DeleteUserInfo(id))
{
//页面重定向
context.Response.Redirect("UserInfoList.ashx");
}
else
{
context.Response.Redirect("Error.html");
}
}
else
{
context.Response.Write("参数错误!!");
}
} public bool IsReusable
{
get
{
return false;
}
}
}
}

2. 通过Ajax删除网页数据

一般删除网页数据和jquery下使用Ajax删除数据的区别的更多相关文章

  1. jQuery 移动端ajax请求列表数据,实现点击翻页效果(还有手势往下滑动翻页)。

    1 首先是html部分 <div class="content"> <div class="list"></div>  // ...

  2. Jquery学习笔记 --ajax删除用户,使用了js原生ajax

    主要复习了php的pdo数据库操作,和js的ajax,真麻烦,希望jquery的ajax简单点. index.php: 1 <!DOCTYPE html> 2 <html lang= ...

  3. 原创:C语言打开、下载、删除网页,统计网页字符个数

    本程序由本人在华夏联盟的ID闪电笨笨原创,首发地址:http://bbs.hx95.com/ 写此程序希望可以可以激发新手学习C语言的积极性! C语言代码实现功能如下:            1.实现 ...

  4. Jquery table元素操作-创建|数据填充|重置|隐藏行

    1.Jquery创建表格 /** * 创建表格 * @param label 标题 json格式,数据结构见附录1 * @param data 数据 json格式,数据结构见附录1 * @param ...

  5. MySQL学习笔记_4_MySQL创建数据表(下)

    MySQL创建数据表(下) 五.数据表类型及存储位置 1.MySQL与大多数数据库不同,MySQL有一个存储引擎概念.MySQL可以针对不同的存储需求选择不同的存储引擎. 2. showengines ...

  6. Android实战简易教程-第二十五枪(基于Baas的数据表查询下拉刷新和上拉载入实现!)

    上一节我们实现了数据表的载入,可是,当数据表数据非常多时.我们就要考虑数据的分页.这里我们选用了PullToRefreshListView控件,先看一下该控件的说明: 效果图:            ...

  7. vue 中使用 AJAX获取数据的方法

    在VUE开发时,数据可以使用jquery和vue-resource来获取数据.在获取数据时,一定需要给一个数据初始值. 看下例: <script type="text/javascri ...

  8. MVC使用jQuery.ajax()删除数据

    jQuery.ajax()可以简写为$.ajax().以前有写过MVC删除的实现,如<MVC实现删除数据库记录> http://www.cnblogs.com/insus/p/336804 ...

  9. springMVC框架下JQuery传递并解析Json数据

    springMVC框架下JQuery传递并解析Json数据

随机推荐

  1. HTML(续)

    1.有frame就无body,框架的noresize:设置框架大小不能改变.2.链接在框架中的应用target:有定为目标的功能.<a href = "链接源地址" targ ...

  2. JDBC的DBUtils源码

    DBUtils源码: package com.it.util; import java.sql.Connection; import java.sql.DriverManager; import ja ...

  3. 余额表前后台操作和对应sql

    发生额的含义:产生于账行表. gl_je_lines账行表——>借贷(会产生额度,即发生额) —————————————————————————— gl_balances余额表: 余额   =  ...

  4. LSTM算法原理理解

    神经网络 模拟人类大脑神经网络结构,每个神经元和其他的神经元相互连接,当它兴奋的时候会向相连的神经元发送化学物质,从而改变神经元的电位,当神经元的电位超过阈值,它会被激活,向其他神经元发送化学物质.其 ...

  5. 使用v-bind处理class与style

    普通的css引入: 变量引入: 通过定义一个变量fontColor来通过v-bind来进行绑定在h3z的class中 <!--变量引入--> <h3 :class="fon ...

  6. tcp编程 示例

    #include <stdio.h> #include <sys/types.h> #include <sys/socket.h> #include <net ...

  7. oracle 12cR2 smart flash cache实测

    最近一直在处理新系统的性能优化问题,这两天特地测试了下oracle 11gR2开始引入的smart flash cache. 其介绍参考MOS文档,How To Size the Database S ...

  8. Redhat6.4安装MongoDBv3.6.3

    运用后台+配置文件方式启动. 条件 下载mongodb-linux-x86_64-rhel62-3.6.3.tar 官网https://www.mongodb.com/download-center? ...

  9. python简说(五)操作文件

    f = open('users.txt',encoding='utf-8') #读文件的时候,必须存在在才可以读 文件对象,或者文件句柄res = f.read()print(res)f.close( ...

  10. centos7 install rabbtimq

    yum install deltarpm erlang wget https://dl.bintray.com/rabbitmq/all/rabbitmq-server/3.7.8/rabbitmq- ...