首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

CheckBoxList通过js获取Value,该如何解决

2012-06-05 
CheckBoxList通过js获取Value一开始想到一种方法foreach (var listItem in backGroundIndustryTreeMods.Se

CheckBoxList通过js获取Value
一开始想到一种方法
foreach (var listItem in backGroundIndustryTreeMods.Select(backGroundIndustryTreeMod => new ListItem(backGroundIndustryTreeMod.Name, backGroundIndustryTreeMod.ID.ToString())))
  {
  listItem.Attributes.Add("alt", listItem.Value);
   
  chkIndustry.Items.Add(listItem);
  }
增加一个Alt属性,这样可以在input前面多一个span可以绑定value,

我需要获取这个id进行异步操作。
但是在提交数据的时候,如果后台的验证没有通过,页面会提交一次,
listItem.Attributes.Add("alt", listItem.Value);
绑定的东西就消失了..请问有没有什么解决方案.?

[解决办法]
在前台验证
[解决办法]
无论成功与否,在重新绑定一次
[解决办法]
使用JQUERY
将CheckBoxList放在div11内
$("#div11 :checkbox").bind("click", function () {
var s = $(this).next();
alert(s.html());
});

$(this).next(); 通过这个方法可以获取复选框后面对应的LABEL元素

热点排行