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);
}
}
}
查看全文
相关阅读:
redis key全量导出与导出指定前缀的key
php魔术变量
搭建高可用mysql系列(2)-- Percona XtraDB Cluster 安装
搭建高可用mysql系列(1)-- Percona XtraDB Cluster介绍
memcached迁移方案——记一次memcached session服务的迁移
php获取两个数组相同的元素(交集)以及比较两个数组中不同的元素(差集)
PHP运行模式简单总结
解决osx下 ssh: connect to host localhost port 22: Connection refused
linux增加自己的可执行目录 $PATH
macbook下 go 语言的 helloworld
原文地址:https://www.cnblogs.com/ganmk/p/1207593.html
最新文章
python json解析字符串出错该如何排查问题
2017最新PHP初级经典面试题目汇总(下篇)
2017最新PHP经典面试题目汇总(上篇)
linux-一篇文章完成lnmp环境的编译安装
Linux必备 -- 如何在Mac OS 使用VMware 安装Linux
SEO -- WP如何建立SiteMap
SEO -- WordPress怎设置百度站长链接自动提交
将博客搬至CSDN
macOS -- Mac系统如何通过终端使用mysql
macOS -- Mac系统如何编辑hosts文件
热门文章
macOS -- 如何通过终端开启/关闭SSH
lnmp -- 解决Warning: scandir() has been disabled for security reasons in…的问题
macOS --- 配置基于域名的虚拟主机
码农常用软件合集
【SQL】修改某个字段的部分内容
【MFC】error C2065: 'AfxGetFileName' : undeclared identifier
【SQL】如何两张表关联查询?
找工作,要做就做最好的自己,大平台去闯闯,一定不要让未来后悔!~附简历
树莓派使用apt-get安装配置Nginx+PHP7+MySQL(MariaDB)附带详细部分
树莓派2、3更换镜像源
Copyright © 2011-2022 走看看