Home > Article > Web Front-end > jquery allows you to edit text by clicking on it and save the modifications to the database_jquery
You can find a lot of this method on the Internet, but many of them only have to click on the text to edit and save, but there is no complete code to write how to save it to the database. Because I have little talent and knowledge, it took me a long time to write and save the modified content to the database with only one SQL statement. Today I will share with you
This is the running picture
This is the front page 03.aspx page
Order Name: | <%#Eval("OrderName")%> | ||||
Product type: | <%#Eval("ID_Product")%> | Status: | < ;%#Eval("OrderState_Send")%> | Print volume: td> | <%#Eval("OrderQty")%> |
Receipt information: | <%#Eval("SendAddress")%> | Total amount: | <%#Eval("OrderMoney_Total")%> |
This is the general handler page< ;span style="font-family:Times New Roman;"> 03.ashx
<%@ WebHandler Language="C#" Class="_03" %>
using System;
using System .Web;
using System.Data.SqlClient;
public class _03 : IHttpHandler {
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/plain";
int OrderId = 5;
string newOrderName = context.Request.QueryString["caname"];//Get the user's modified text
string updateCol = context.Request.QueryString["updateCol"];//Get the value of the id of the previous td modified by the user (this id is the same as the column name in the database)
string sql = "update eoPrintOrder set " updateCol " =@name where Id_order=@id";//Through this sql statement, you can modify the database SqlParameter[] pams = {
new SqlParameter("@name",newOrderName),
new SqlParameter("@id",OrderId)
};
string data = DscySFL.DbHelp.ExecuteCommand(sql,pams).ToString();
context.Response .Write(data);
}
public bool IsReusable {
get {
return false;
}
}