function
CheckAll()
{
for ( var i = 0 ; i < document.form1.commentid.length; i ++ )
{
if (document.form1.commentid[i].checked == false )
document.form1.commentid[i].checked = true ;
else
document.form1.commentid[i].checked = false ;
}
}
{
for ( var i = 0 ; i < document.form1.commentid.length; i ++ )
{
if (document.form1.commentid[i].checked == false )
document.form1.commentid[i].checked = true ;
else
document.form1.commentid[i].checked = false ;
}
}
<
input
type
="button"
name
="checkAll"
value
="选中本页所有项"
onclick
="CheckAll();"
class
="inputbut"
/>
1.放在Repeater控件中使用:
<
asp:Repeater
ID
="rptMsgList"
runat
="server"
>
< ItemTemplate >
< dt class ="dt" >
< input type ="checkbox" name ="commentid" id ="commentid" value ="<%#Eval(" id") % > " />
< img src ="../images/pic/icon.jpg" alt ="" />
<% --< span class = " msgtitle " > # < %# _rsCount + 1 - (Container.ItemIndex + 1 + _PageSize * (page - 1 )) %> 楼 </ span > --%>
</ dt >
< dt class ="dd" >
<% #NT.Common.NTString.toHtml( Eval ( " msgcontent " ).ToString()) %>
</ dt >
</ ItemTemplate >
</ asp:Repeater >
< ItemTemplate >
< dt class ="dt" >
< input type ="checkbox" name ="commentid" id ="commentid" value ="<%#Eval(" id") % > " />
< img src ="../images/pic/icon.jpg" alt ="" />
<% --< span class = " msgtitle " > # < %# _rsCount + 1 - (Container.ItemIndex + 1 + _PageSize * (page - 1 )) %> 楼 </ span > --%>
</ dt >
< dt class ="dd" >
<% #NT.Common.NTString.toHtml( Eval ( " msgcontent " ).ToString()) %>
</ dt >
</ ItemTemplate >
</ asp:Repeater >
2.后台cs获取:
protected
void
btnPass_Click(
object
sender, EventArgs e)
{
bool brt = false ;
string [] commentids = Request[ " commentid " ].Split( new char [] { ' , ' }, StringSplitOptions.RemoveEmptyEntries);
foreach ( string id in commentids)
{
brt = comment.CommentCheck(Convert.ToInt32(id));
}
DisPlayCommentList();
}
{
bool brt = false ;
string [] commentids = Request[ " commentid " ].Split( new char [] { ' , ' }, StringSplitOptions.RemoveEmptyEntries);
foreach ( string id in commentids)
{
brt = comment.CommentCheck(Convert.ToInt32(id));
}
DisPlayCommentList();
}