我想做一个和QQ评论差不多功能的界面就是看到别人的评论你可以支持也可以点反对,点了支持或者反对后边上的数字就会加1然后这一条评就不能论点击了,除非关闭页面再打开.
代码如下:前台aspx代码
<asp:Repeater ID="Repeater2" runat="server" onitemcommand="Repeater2_ItemCommand">
<ItemTemplate>
<tr>
<td class="gray14" colspan="2" height="60" valign="top" style=" padding-left:8px;" ><%#DataBinder.Eval(Container.DataItem, "Comments_Content")%></td>
</tr>
<tr>
<td align="right" colspan="2" height="40" class="usname"><asp:HiddenField ID="hiddCommentsID" runat="server" Value='<%#DataBinder.Eval(Container.DataItem,"Comments_ID") %>'/>
<asp:LinkButton runat="server" ID="BtnSupport" CommandName="BtnSupport">支持</asp:LinkButton>[<%#DataBinder.Eval(Container.DataItem, "Comments_Support")%>]
<asp:LinkButton ID="BtnOppose" CommandName="BtnOppose" runat="server" >反对</asp:LinkButton>[<%#DataBinder.Eval(Container.DataItem, "Comments_Oppose")%>]</td>
</tr>
</ItemTemplate>
</asp:Repeater> 后台CS代码:
protected void Repeater2_ItemCommand(object source, RepeaterCommandEventArgs e)
{
HiddenField CommentsID = (HiddenField)e.Item.FindControl("hiddCommentsID");
LinkButton lb;
switch (e.CommandName.ToLower())
{
case "btnsupport": //支持
objCommentInfo = objcomment.GetInfo(int.Parse(CommentsID.Value.Trim()));
objCommentInfo.Comments_Support++;
objcomment.update(objCommentInfo);
DateBin();
break; case "btnoppose": //反对
objCommentInfo = objcomment.GetInfo(int.Parse(CommentsID.Value.Trim()));
objCommentInfo.Comments_Oppose++;
objcomment.update(objCommentInfo);
DateBin();
break;
}
}我现在能实现点击后增加支持和反对人数,就是不能让他点后变灰色,不可再点了!!有什么办法吗?
代码如下:前台aspx代码
<asp:Repeater ID="Repeater2" runat="server" onitemcommand="Repeater2_ItemCommand">
<ItemTemplate>
<tr>
<td class="gray14" colspan="2" height="60" valign="top" style=" padding-left:8px;" ><%#DataBinder.Eval(Container.DataItem, "Comments_Content")%></td>
</tr>
<tr>
<td align="right" colspan="2" height="40" class="usname"><asp:HiddenField ID="hiddCommentsID" runat="server" Value='<%#DataBinder.Eval(Container.DataItem,"Comments_ID") %>'/>
<asp:LinkButton runat="server" ID="BtnSupport" CommandName="BtnSupport">支持</asp:LinkButton>[<%#DataBinder.Eval(Container.DataItem, "Comments_Support")%>]
<asp:LinkButton ID="BtnOppose" CommandName="BtnOppose" runat="server" >反对</asp:LinkButton>[<%#DataBinder.Eval(Container.DataItem, "Comments_Oppose")%>]</td>
</tr>
</ItemTemplate>
</asp:Repeater> 后台CS代码:
protected void Repeater2_ItemCommand(object source, RepeaterCommandEventArgs e)
{
HiddenField CommentsID = (HiddenField)e.Item.FindControl("hiddCommentsID");
LinkButton lb;
switch (e.CommandName.ToLower())
{
case "btnsupport": //支持
objCommentInfo = objcomment.GetInfo(int.Parse(CommentsID.Value.Trim()));
objCommentInfo.Comments_Support++;
objcomment.update(objCommentInfo);
DateBin();
break; case "btnoppose": //反对
objCommentInfo = objcomment.GetInfo(int.Parse(CommentsID.Value.Trim()));
objCommentInfo.Comments_Oppose++;
objcomment.update(objCommentInfo);
DateBin();
break;
}
}我现在能实现点击后增加支持和反对人数,就是不能让他点后变灰色,不可再点了!!有什么办法吗?
解决方案 »
- ajax客户端无刷新的省市区联动
- 求datalist实现分页代码,弄了半天没弄出来
- 急!急!急!为什么我的IE9不自动加载NET的__doPostBack方法
- 关于执行数据库操作语句com.ExecuteScalar()时出现异常,求助。。。
- 怎样判断GridView是否处于编辑状态?
- C#后台代码中如何让页面刷新?
- ==========================菜鸟求教,网页上图片显示的问题============================
- [求助]如何把SQL脚本转换成Html文件。。。
- 比如:http://localhost/filepath/files/abc.doc,要如何进行权限验证??
- 百度地图api请问是不是要进行开发者验证后,申请的keu才能用。
- 奇怪错误~~~控件包含代码块(即 <% ... %>),因此无法修改控件集合。~~在线等~~
- asp.net如何判断用户重复登录
{
get{return (bool)ViewState["b"];}
set{ViewState["b"]=value;}
}
设置标识
LinkButton lbtn=e.Item.FindControl( "BtnSupport") as LinkButton;
if(lbtn!=null){}
protected void Repeater2_ItemCommand(object source, RepeaterCommandEventArgs e)
{
LinkButton lb=(LinkButton)e.CommandSource;
int Index = ((RepeaterItem)(lb.NamingContainer)).ItemIndex;//获得行号
((LinkButton)Repeater2.Items[Index].FindControl("btnoppose")).Enabled = false;
((LinkButton)Repeater2.Items[Index].FindControl("btnsupport")).Enabled = false;
.........................
}