日期:2014-05-17  浏览次数:20572 次

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元素