ASP.net不能设置复选框的价值! [英] ASP.net can't set checkboxes value!

查看:110
本文介绍了ASP.net不能设置复选框的价值!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CheckBox newBox = new CheckBox();
newBox.Text = dtCommon[i].userName;
newBox.CssClass = "cbox";
newBox.Attributes["value"] = dtCommon[i].id.ToString();
ApprovalSelectPanel.Controls.Add(newBox);

将呈现为:

<input id="ctl00_mainContent_ctl00" type="checkbox" name="ctl00$mainContent$ctl00" checked="checked" />

我怎样才能得到一个值的属性?我的JQuery需要访问这个!

How can I get a value attribute on? My JQuery needs to access this!

推荐答案

我敢打赌,你这是设置属性,但在含跨度(查找一个元素)

I bet you it is setting the attribute, but on the containing span (look up one element).

您想使用InputAttributes属性,而不是:

You want to use the InputAttributes property instead:

newBox.InputAttributes["value"] = dtCommon[i].id.ToString();

这篇关于ASP.net不能设置复选框的价值!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆