一般删除网页数据和jquery下使用Ajax删除数据的区别
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删除数据的区别的更多相关文章
- jQuery 移动端ajax请求列表数据,实现点击翻页效果(还有手势往下滑动翻页)。
1 首先是html部分 <div class="content"> <div class="list"></div> // ...
- Jquery学习笔记 --ajax删除用户,使用了js原生ajax
主要复习了php的pdo数据库操作,和js的ajax,真麻烦,希望jquery的ajax简单点. index.php: 1 <!DOCTYPE html> 2 <html lang= ...
- 原创:C语言打开、下载、删除网页,统计网页字符个数
本程序由本人在华夏联盟的ID闪电笨笨原创,首发地址:http://bbs.hx95.com/ 写此程序希望可以可以激发新手学习C语言的积极性! C语言代码实现功能如下: 1.实现 ...
- Jquery table元素操作-创建|数据填充|重置|隐藏行
1.Jquery创建表格 /** * 创建表格 * @param label 标题 json格式,数据结构见附录1 * @param data 数据 json格式,数据结构见附录1 * @param ...
- MySQL学习笔记_4_MySQL创建数据表(下)
MySQL创建数据表(下) 五.数据表类型及存储位置 1.MySQL与大多数数据库不同,MySQL有一个存储引擎概念.MySQL可以针对不同的存储需求选择不同的存储引擎. 2. showengines ...
- Android实战简易教程-第二十五枪(基于Baas的数据表查询下拉刷新和上拉载入实现!)
上一节我们实现了数据表的载入,可是,当数据表数据非常多时.我们就要考虑数据的分页.这里我们选用了PullToRefreshListView控件,先看一下该控件的说明: 效果图: ...
- vue 中使用 AJAX获取数据的方法
在VUE开发时,数据可以使用jquery和vue-resource来获取数据.在获取数据时,一定需要给一个数据初始值. 看下例: <script type="text/javascri ...
- MVC使用jQuery.ajax()删除数据
jQuery.ajax()可以简写为$.ajax().以前有写过MVC删除的实现,如<MVC实现删除数据库记录> http://www.cnblogs.com/insus/p/336804 ...
- springMVC框架下JQuery传递并解析Json数据
springMVC框架下JQuery传递并解析Json数据
随机推荐
- Spring Boot 中使用 @ConfigurationProperties 注解
@ConfigurationProperties 主要作用:绑定 application.properties 中的属性 例如: @Configuration public class DataSou ...
- git getting started
2019/4/25-- after committing to blessed. modify dependency file to download file so as to get latest ...
- asyncio 中给running 的loop 动态添加 Future Task
https://my.oschina.net/backbye/blog/1919486 asyncio 提供了两个给运行中的事件循环(loop) 添加 事件的方法 call_soon_threadsa ...
- mysql日志种类、二进制日志模式、mysqlbinlog解析二进制日志
mysql日志的种类 二进制日志(binary log):记录数据更新的操作,mysqlbinlog 可查看二进制日志文件 错误日志(error log):记录mysql服务进程mysqld的启动.关 ...
- VR AR MR
VR.AR和MR的区别? VR就是创造一个完全取代现实的世界,让人感觉「我怎么在这里?」 AR则是在现实世界的图像中叠加一些东西,让人感觉「哎?这里多了个本来不存在的东西」 MR则是虚拟物体完全和现实 ...
- oracle常用SQL——创建用户、表空间、授权(12C)
一.查询 查询用户所属 表空间 select username,default_tablespace from dba_users where username='xxx' 查询表空间情况 SELEC ...
- http请求记录
Request Headers 请求头 Content-Type 默认值: "application/x-www-form-urlencoded".发送信息至服务器时内容编码类型 ...
- tp5 中使用自定义扩展类和函数
如果是要引用其它控制器里定义的方法参考:https://www.cnblogs.com/efyefy/p/8796014.html 如果在extend定义的类和函数默认是在全局命名空间下的 new \ ...
- QML使用的内置对象
QML从ECMAScript继承而来,所以支持这个ECMAScript.经常在QML工程中看到Math.Data.....等方法,但是在Qt手册里搜索不到,这是因为这些方法不是QtQuick的,而是E ...
- Android中activity的四个启动模式
activity的四个启动方式分别是standard.singletop.singletask.singleinstance.第一个其实就是只要新打开活动就会新建一个实例.第二个顾名思义返回栈的顶部只 ...