Python语言技术文档

微信小程序技术文档

php语言技术文档

jsp语言技术文档

asp语言技术文档

C#/.NET语言技术文档

html5/css技术文档

javascript

点击排行

您现在的位置:首页 > 技术文档 > ajax

asp.net 全部选中与取消操作,选中后的删除(ajax)实现无刷新效果

来源:中文源码网    浏览:112 次    日期:2024-05-14 21:25:06
【下载文档:  asp.net 全部选中与取消操作,选中后的删除(ajax)实现无刷新效果.txt 】


asp.net 全部选中与取消操作,选中后的删除(ajax)实现无刷新效果
前台代码复制代码 代码如下::<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 用户信息操作
后台代码: 复制代码 代码如下:using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; using System.Text; public partial class _Default : System.Web.UI.Page { string Straction = ""; protected void Page_Load(object sender, EventArgs e) { Straction = Request["action"]; if(Straction=="action") { UserInfo(); } if (Straction == "Delete") { DeleteUser(); } } /// /// 周昕 2009-6-8号加载用户详细信息 /// public void UserInfo() { SqlConnection mycon = new SqlConnection(); mycon.ConnectionString = ConfigurationManager.ConnectionStrings["BoBoConn"].ToString(); string sql = "select * from loginuser"; SqlCommand mycom = new SqlCommand(sql, mycon); mycon.Open(); SqlDataReader myda = mycom.ExecuteReader(); StringBuilder str = new StringBuilder(); str.Append(""); while (myda.Read()) { str.Append(""); str.Append(""); str.Append(""); } str.Append("
全选用户名用户全名
"); str.Append("" + myda["UserName"].ToString() + "" + myda["FullName"].ToString() + "
"); str.Append("
"); Response.Clear(); Response.ContentType = "application/text"; Response.Write(str); Response.End(); } /// /// 周昕 2009-6-8 删除选中用户的详细信息 /// public void DeleteUser() { //获取用户ID string strID = Request["userid"]; string Userid = strID.Substring(0, strID.Length - 1); //转换成为数组 string[] stridArray = Userid.Trim().Split(','); string sql = "delete from loginuser where ID='" + stridArray[0].ToString() + "'"; for (int i = 0; i < stridArray.Length; i++) { string id = stridArray[i].ToString(); sql += "or ID='" + id + "'"; } SqlConnection mycon = new SqlConnection(); mycon.ConnectionString = ConfigurationManager.ConnectionStrings["BoBoConn"].ToString(); mycon.Open(); SqlCommand mycom = new SqlCommand(sql, mycon); int n = (int)mycom.ExecuteNonQuery(); mycon.Close(); if (n > 0) { Response.Clear(); Response.ContentType = "application/text"; Response.Write("ok"); Response.End(); } else { Response.Clear(); Response.ContentType = "application/text"; Response.Write("no"); Response.End(); } } } 效果图:

相关内容