前端:
function Un_Enable(code)
{
$.ajax({
type: 'get',
url: 'UserLogOn.aspx',
datatype:"json",
contentType:"application/json;charset=utf-8",
data:{action:'UnEnable',usercode:code},
async: true,
success: function (result) {
alert(result);
},
error: function () {
setContainer('ERROR!');
}
});
}
后台:
protected void Page_Load(object sender, EventArgs e)
{
string action = Request.QueryString["action"];
string usercode = Request.QueryString["usercode"];
if (!string.IsNullOrEmpty(action))
{
switch (action)
{
case "UnEnable":
UnEnable(usercode);
break;
}
}
}
public void UnEnable(string code)
{
string result = "";
try
{
DataBase.DataHelper DHp = new DataBase.DataHelper();
DHp.ExecCommand("update table set Enable='False' where code='" + code + "'");
result = "{\"state\":\"1\",\"message\":\"禁用成功!\"}";
}
catch (Exception ex)
{
result = "{\"state\":\"0\",\"message\":\"禁用失败!原因:" + ex.Message.ToString() + "\"}";
}
Response.Write(result);
Response.End();
}