麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

BS常用方法備忘

2019-11-17 01:47:18
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
BS常用方法備忘

在B/S項(xiàng)目開(kāi)發(fā)過(guò)程中總結(jié)的一些常用方法,如:常量、驗(yàn)證方法、服務(wù)器控件方法、html控件方法等。

  1 ///******************* 說(shuō)明 ***************************///  2 ///     作者:清風(fēng)攜夕陽(yáng)  3 ///     時(shí)間:2014-09-29  4 ///     描述:Web服務(wù)端控件輔助類(lèi),程序開(kāi)發(fā)過(guò)程中常用方法  5 ///***************************************************///  6 using System;  7 using System.Data;  8 using System.Collections.Generic;  9 using System.Web.UI.WebControls; 10 namespace Common 11 { 12     /// <summary> 13     /// Web服務(wù)端控件輔助類(lèi) 14     /// </summary> 15     [Serializable] 16     public static class WebHelper 17     { 18         #region 常量、靜態(tài)變量 19         /// <summary> 20         /// 8位時(shí)間格式y(tǒng)yyymmdd 21         /// </summary> 22         public static string time8 = "yyyymmdd"; 23         /// <summary> 24         /// 10位時(shí)間格式y(tǒng)yyy-mm-dd 25         /// </summary> 26         public static string time10 = "yyyy-mm-dd"; 27         /// <summary> 28         /// 通用空值選項(xiàng)文本 29         /// </summary> 30         public static string emptySelect = "--請(qǐng)選擇--"; 31         #endregion 32         #region 驗(yàn)證、檢測(cè)方法 33          /// <summary> 34          /// 驗(yàn)證sql匹配條件是否正確(若以and開(kāi)頭則自動(dòng)去除) 35          /// </summary> 36          /// <param name="strWhere">sql匹配條件</param> 37         public static string CheckStrWhere(string strWhere) 38         { 39             string str = strWhere.TrimStart();//去除前置空格 40             if (str.ToLower().IndexOf("and ") == 0)//若以and開(kāi)頭則自動(dòng)去除第一個(gè)and 41             { 42                 strWhere = str.Substring(4);//若要保留前面一個(gè)空格,可以改為3 43             } 44             return strWhere; 45         } 46         #endregion 47         #region 服務(wù)端控件方法 48  49         #region CheckBoxList 50         /// <summary> 51         /// 獲取CheckBoxList選中項(xiàng)數(shù)目 52         /// </summary> 53         public static int CheckedCount(CheckBoxList ckboxlist) 54         { 55             int count = 0; 56             foreach (ListItem item in ckboxlist.Items) 57             { 58                 if (item.Selected == true) 59                 { 60                     count++; 61                 } 62             } 63             return count; 64         } 65         /// <summary> 66         /// 根據(jù)選項(xiàng)值選中CheckBoxList選項(xiàng) 67         /// </summary> 68         public static void SetChecked(CheckBoxList cboxlist, List<string> vals) 69         { 70             if (vals == null || vals.Count == 0) 71             { 72                 return; 73             } 74             for (int i = 0; i < cboxlist.Items.Count; i++) 75             { 76                 ListItem item = cboxlist.Items[i]; 77                 for (int j = 0; j < vals.Count; j++) 78                 { 79                     if (item.Value == vals[j]) 80                     { 81                         item.Selected = true; 82                         vals.Remove(vals[j]); 83                         break; 84                     } 85                 } 86                 if (vals.Count == 0) 87                 { 88                     return; 89                 } 90             } 91         } 92         /// <summary> 93         /// 獲取CheckBoxList選中項(xiàng)的值 94         /// </summary> 95         public static List<string> GetChecked(CheckBoxList cboxlist) 96         { 97             List<string> vals = new List<string>(); 98             foreach (ListItem item in cboxlist.Items) 99             {100                 if (item.Selected == true)101                 {102                     vals.Add(item.Value);103                 }104             }105             return vals;106         }107         /// <summary>108         /// 清空選項(xiàng)109         /// </summary>110         public static void ClearChecked(CheckBoxList cboxlist)111         {112             foreach (ListItem item in cboxlist.Items)113             {114                 item.Selected = false;115             }116         }117         /// <summary>118         /// 全選119         /// </summary>120         public static void CheckAll(CheckBoxList cboxlist)121         {122             foreach (ListItem item in cboxlist.Items)123             {124                 item.Selected = true;125             }126         }127         /// <summary>128         /// 反選129         /// </summary>130         public static void CheckNotChecked(CheckBoxList cboxlist)131         {132             foreach (ListItem item in cboxlist.Items)133             {134                 item.Selected = !item.Selected;135             }136         }137         /// <summary>138         /// 根據(jù)數(shù)據(jù)表綁定CheckBoxList控件139         /// </summary>140         /// <param name="dt">數(shù)據(jù)表</param>141         /// <param name="TextField">選項(xiàng)名稱(chēng)列編碼</param>142         /// <param name="ValueField">選項(xiàng)值列編碼</param>143         public static void BindCheckBoxList(CheckBoxList cboxlist, DataTable dt, string TextField, string ValueField)144         {145             cboxlist.Items.Clear();146             if (dt != null && dt.Rows.Count > 0)147             {148                 cboxlist.DataSource = dt;149                 cboxlist.DataTextField = TextField;150                 cboxlist.DataValueField = ValueField;151                 cboxlist.DataBind();152             }153         }154         #endregion155         #region RadioButtonList156         /// <summary>157         /// 根據(jù)數(shù)據(jù)表綁定RadioButtonList控件158         /// </summary>159         /// <param name="dt">數(shù)據(jù)</param>160         /// <param name="TextField">選項(xiàng)名稱(chēng)列編碼</param>161         /// <param name="ValueField">選項(xiàng)值列編碼</param>162         public static void BindRadioButtonList(RadioButtonList rdolist, DataTable dt, string TextField, string ValueField)163         {164             rdolist.Items.Clear();165             if (dt != null && dt.Rows.Count > 0)166             {167                 rdolist.DataSource = dt;168                 rdolist.DataTextField = TextField;169                 rdolist.DataValueField = ValueField;170                 rdolist.DataBind();171             }172         }173         #endregion174         #region DropDownList175         /// <summary>176         /// 根據(jù)數(shù)據(jù)表綁定RadioButtonList控件177         /// </summary>178         /// <param name="dt">數(shù)據(jù)表</param>179         /// <param name="TextField">選項(xiàng)名稱(chēng)列編碼</param>180         /// <param name="ValueField">選項(xiàng)值列編碼</param>181         /// <param name="ListName">空值顯示文本,若為空則無(wú)空值選項(xiàng)</param>182         public static void BindDropDownList(DropDownList dlist, DataTable dt, string TextField, string ValueField, string EmptyValueText)183         {184             dlist.Items.Clear();185             if (dt != null && dt.Rows.Count > 0)186             {187                 dlist.DataSource = dt;188                 dlist.DataTextField = TextField;189                 dlist.DataValueField = ValueField;190                 dlist.DataBind();191             }192             if (!String.IsNullOrEmpty(EmptyValueText))193             {194                 dlist.Items.Insert(0, new ListItem(EmptyValueText, ""));195             }196         }197         #endregion198         #region ListBox199         /// <summary>200         /// 根據(jù)數(shù)據(jù)表綁定ListBox控件201         /// </summary>202         /// <param name="dt">數(shù)據(jù)表</param>203         /// <param name="TextField">選項(xiàng)名稱(chēng)列編碼</param>204         /// <param name="ValueField">選項(xiàng)值列編碼</param>205         public static void BindListBox(ListBox lbox, DataTable dt, string TextField, string ValueField)206         {207             lbox.Items.Clear();208             if (dt != null && dt.Rows.Count > 0)209             {210                 lbox.DataSo
發(fā)表評(píng)論 共有條評(píng)論
用戶(hù)名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 人人舔人人舔 | 久久久久久久亚洲视频 | 9999久久久久久 | 国产九色视频在线观看 | 激情亚洲一区二区 | 日韩精品无码一区二区三区 | 一级黄色欧美 | 国产pron | 久久新地址 | 极品xxxx欧美一区二区 | 日本免费一区二区三区四区 | 男人的天堂色偷偷 | 91精品国产综合久久久动漫日韩 | www.99re14.com | 亚洲精品午夜电影 | 激情在线免费观看 | 精品国产乱码久久久久久久久 | 一级免费| 中文字幕一二三区芒果 | av免播放| 久久性生活免费视频 | free性欧美hd另类 | 国产流白浆高潮在线观看 | 成人福利在线播放 | 久久大陆 | 久久久av影视 | 性大片免费看 | 亚洲第一成av人网站懂色 | 激情黄页| 91久久国产露脸精品国产护士 | 久久久久久久久久久久久久国产 | 欧美一级黄色片在线观看 | 国产成人高清在线 | 在线中文字幕不卡 | 精品在线观看一区二区三区 | 在线中文字幕观看 | 久久成人视屏 | 欧美激情猛片xxxⅹ大3 | 在线小视频国产 | 免费观看视频在线观看 | 免费观看国产视频 |