public bool IsReusable
{
get
{
return false;
}
}
}
}
再说客服端,因为用的JQuery,活就很少了。使用的$.get方法。
先请求服务端,传入两个参数:state和id,收到服务端数据后更改状态。
主要代码:
复制代码 代码如下:
function change(id, state) {
$.get("./Ajax/ChangeState.ashx", { id: id, state: state }, function (data, textStatus) {
if (textStatus == "success") {
switch (state) {
case 0:
$("#Support" + id).text("顶(" + data + ") ");
break;
case 1:
$("#Opposition" + id).text("踩(" + data + ") ");
break;
}
}
});
}
页面代码:
复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ViewDetail.aspx.cs" Inherits="AjaxDemo.ViewDetail" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src=https://www.jb51.net/htynkn/archive/2012/01/31/"Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
function change(id, state) {
$.get("./Ajax/ChangeState.ashx", { id: id, state: state }, function (data, textStatus) {
if (textStatus == "success") {
switch (state) {
case 0:
$("#Support" + id).text("顶(" + data + ") ");
break;
case 1:
$("#Opposition" + id).text("踩(" + data + ") ");
break;
}
}
});
}
</script>
</head>
<body>
<form runat="server">
<div>
<h4>标题</h4>
<h1>
<asp:Label runat="server" Text=""></asp:Label></h1>
</div>