PS:最近在做權限管理這個模塊,發現用checkbox的地方挺多的,于是寫了個簡單的例子,以供以后學習和使用。
1.前端頁面:
<form method="get" runat="server"> <input type="checkbox" value="3" />張三 <input type="checkbox" value="4" />李四 <input type="checkbox" value="5" />王五 <input type="checkbox" value="6" />趙六 <input type="checkbox" value="7" />孫琦 <input type="checkbox" value="8" />豬八 <input type="submit" value="提交" /> </form>
2.后臺方法:
#region 獲取從前端頁面回傳過來的 CheckBox 的值 void GetCheckBoxValue() /// <summary> /// 獲取從前端頁面回傳過來的 CheckBox 的值 /// <para>Request.Form["chk_per"] 以逗號分割,獲取所有選中的 CheckBox 的值</para> /// </summary> 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(); }}
Tags:WebForm checkbox
上一篇:.NET中獲取程序根目錄的常用方法介紹
下一篇:下面沒有鏈接了
相關文章
文章評論
最 近 更 新
熱 點 排 行
關于我們 - 廣告合作 - 聯系我們 - 免責聲明 - 網站地圖 - 投訴建議 - 在線投稿
CopyRight © 2006-2014 腳本之家 JB51.Net , All Rights Reserved
新聞熱點
疑難解答
圖片精選