$(“#test”).text(“类别修改失败,请检查是否类别名称重复!”);
input_keydown.trigger(“focus”).trigger(“select”); // 文本框全选
} else {
$(“#test”).text(“”);
objTD.html(newText);
}
});
} else {
// 前后文本一致,把文本框变成标签
objTD.html(newText);
}
break;
case 27: // 按下Esc键, 取消修改,把文本框变成标签
$(“#test”).text(“”);
objTD.html(oldText);
break;
}
});
});
});
// 屏蔽Enter按键
$(document).keydown(function(event) {
switch (event.keyCode) {
case 13: return false;
}
});
下面是 一般处理程序代码 ChangeCaName.ashx
<%@ WebHandler Language=”C#” Class=”ChangeCaName” %>
using System;
using System.Web;
using BLL;
using Model;
public class ChangeCaName : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = “text/plain”;
string caid = context.Request.QueryString[“caid”];
string caname = context.Server.UrlDecode(context.Request.QueryString[“caname”]);
// 判断数据库中是否已经存在同名类别
if (new CategoryManager().IsExists(caname))
{
context.Response.Write(“false”);
return;
}
// 更改数据库类别名
Category ca = new Category(caid, caname);
bool b = new CategoryManager().Update(ca);
if (b)
{
context.Response.Write(“true”);
}
else
{
context.Response.Write(“false”);
}
}
public bool IsReusable
{
get
{
return false;
}
}
}










