您现在的位置是:网站首页> 编程资料编程资料

WebForm获取checkbox选中的值(几个简单的示例)_实用技巧_

2023-05-24 365人已围观

简介 WebForm获取checkbox选中的值(几个简单的示例)_实用技巧_

PS:最近在做权限管理这个模块,发现用checkbox的地方挺多的,于是写了个简单的例子,以供以后学习和使用。

1.前端页面:

张三 李四 王五 赵六 孙琦 猪八

2.后台方法:

 #region 获取从前端页面回传过来的 CheckBox 的值 void GetCheckBoxValue() ///  /// 获取从前端页面回传过来的 CheckBox 的值 /// Request.Form["chk_per"] 以逗号分割,获取所有选中的 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 + " | "; } } #endregion
 protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { //测试调用 GetCheckBoxValue(); } }

-六神源码网