PS:最近在做权限管理这个模块,发现用checkbox的地方挺多的,于是写了个简单的例子,以供以后学习和使用。
1.前端页面:
2.后台方法:
#region 获取从前端页面回传过来的 CheckBox 的值 void GetCheckBoxValue() ////// 获取从前端页面回传过来的 CheckBox 的值 /// private void GetCheckBoxValue() { string user = Request["chk_per"]; string[] users = user.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries); string s = string.Empty; foreach (var item in users) { s += item + " | "; } } #endregionRequest.Form["chk_per"] 以逗号分割,获取所有选中的 CheckBox 的值 ///
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
//测试调用
GetCheckBoxValue();
}
}


