获取CheckBox的值

前台获取

   function chkCheckBox() {
            var code_arr = new Array(); //定义一数组
            $('.C_B').each(function () {
                if ($(this).prop("checked")) {
                    if ($(this).val() != "")
                    code_arr.push($(this).val());
                }
            });
            if (code_arr.length == "") {
                alert("请先选择之后再点击下一步!");
                return false;
            }
            return true;
        }

后台获取 asp.net webform情况下的

<td>
      <input type="checkbox" value='<%# Eval("ID") %>' id="Check_Box" class="C_B" runat="server" /> 
 </td>
        /// <summary>
        /// 下一步按钮
        /// </summary>
        protected void btnnext_Click(object sender, EventArgs e)
        {
            List<string> IdArr = new List<string>();
          
            //遍历repeater控件的itemtemplate模版  
            foreach (RepeaterItem item in rptData.Items)
            {
                HtmlInputCheckBox cb = (HtmlInputCheckBox)item.FindControl("Check_Box"); //根据控件id获得控件对象,cdDelete是checkBox控件的id  
                if (cb.Checked == true)
                {
                    IdArr.Add(cb.Value);
                }
            } 
        }

 

posted @ 2017-04-27 14:56  幽冥狂_七  阅读(2939)  评论(0编辑  收藏  举报