若在CS里调用
CheckBoxID.Attributes.Add("OnCheckedChanged", "方法()")
GridView中:
((CheckBox)e.Row.FindControl ("CheckBoxID")).Attributes.Add ("onclick" , "javascript:方法(this.form)")
<script type="text/javascript">window.onload = function() {
// 创建 input 元素
var checkbox = document.createElement("input")
checkbox.type = "checkbox"
checkbox.value = "123"
// 页面添加 checkbox
document.body.appendChild(checkbox)
// 点击
checkbox.onclick = function() {
if(this.checked) {
alert("选中")
}
else {
alert("未选中")
}
alert("value: " + this.value)
}
}
</script>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)