zoukankan
html css js c++ java
asp.net动态加载checkbox的全选/全不选
asp.net动态加载checkbox的全选/全不选:以下为演示例子
CheckAlll.aspx
<%
@ Page Language
=
"
C#
"
AutoEventWireup
=
"
true
"
CodeBehind
=
"
CheckAll.aspx.cs
"
Inherits
=
"
TJBASE.Web.CheckAll
"
%>
<!
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"
>
<
title
>
无标题页
</
title
>
<
script
type
="text/javascript"
language
="javascript"
>
function
CheckAll(idString,o)
{
var
ShValues
=
idString.split(
'
||
'
);
var
i;
for
(i
=
0
;i
<
ShValues.length
-
1
;i
++
)
{
document.getElementById(ShValues[i]).checked
=
o.checked;
}
}
</
script
>
</
head
>
<
body
>
<
form
id
="form1"
runat
="server"
>
<
div
>
</
div
>
</
form
>
</
body
>
</
html
>
CheckAll.asp.cs
using
System;
using
System.Data;
using
System.Configuration;
using
System.Collections;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
namespace
TJBASE.Web
{
public
partial
class
CheckAll : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
FillCheckBox();
}
protected
void
FillCheckBox()
{
//
字符串ID集合
string
strCheckBoxIDSet
=
""
;
//
动态加载checkbox
for
(
int
i
=
0
; i
<
50
; i
++
)
{
CheckBox m_CheckBox
=
new
CheckBox();
m_CheckBox.ID
=
i.ToString();
m_CheckBox.Text
=
i.ToString();
form1.Controls.Add(m_CheckBox);
//
ID以“||”连接成字符串
strCheckBoxIDSet
=
strCheckBoxIDSet
+
m_CheckBox.ID.ToString()
+
"
||
"
;
}
CheckBox m_CheckBox1
=
new
CheckBox();
m_CheckBox1.ID
=
"
checkAll
"
;
m_CheckBox1.Text
=
"
全选
"
;
//
全选动作事件
m_CheckBox1.Attributes.Add(
"
onclick
"
,
"
CheckAll('
"
+
strCheckBoxIDSet
+
"
',this)
"
);
form1.Controls.Add(m_CheckBox1);
}
}
}
查看全文
相关阅读:
洛谷 P5043 树的同构 题解
CF 1178E Archaeology 题解
UVA 1642 MagicalGCD 题解
洛谷 P3919 可持久化线段树 题解
SPOJ 4003 Phone List 题解
OI/ACM最全卡常大招
洛谷 P3368 树状数组 题解
逆序对
洛谷 U78696 图书馆馆长的考验 题解
原创 疲劳炉石传说
原文地址:https://www.cnblogs.com/ganmk/p/1207593.html
最新文章
从fileGDB中获取List
Help library 安装arcobjects for .NET异常问题
怎样将shp文件的坐标点导出来?
如何快速地拆分合并的单元格并填充数据
Mapnik使用postgres中的栅格数据
Error: pgraster_wkb_reader: grayscale band type 10 unsupported
洛谷 P1508 Likecloud 题解
洛谷 P2032 扫描 题解
洛谷 P1801 黑匣子 题解
洛谷 P3386 二分图匹配 题解
热门文章
洛谷 P3388 割点(割顶) 题解
洛谷 P4779 单源最短路径(标准版) 题解
洛谷 P1199 三国游戏 题解
HDU1846 Brave Game 题解
洛谷 P5150 生日礼物 题解
洛谷 P1972 HH的项链 题解
高精运算重载运算符模板
自动AC机
洛谷 P1182 数列分段 题解
洛谷 P3834 卢卡斯定理 题解
Copyright © 2011-2022 走看看