.net不常见的方法小结【欢迎参考使用】
.net不常用通用方法总结,基于日常操作浏览行为而来。有的仅为实现某一细微效果。个人搜集总结,供大家参考。
/// <summary>清除页面所有文本框值(适用客户端端控件) /// ex:FindHtmlInputText(this); /// </summary> /// <param name="c"></param> public void FindHtmlInputText(Control c) { if (c.Controls != null) { foreach (Control x in c.Controls) { if (x is System.Web.UI.HtmlControls.HtmlInputText) { ((System.Web.UI.HtmlControls.HtmlInputText) x).Value = string.Empty; } if (x is System.Web.UI.HtmlControls.HtmlTextArea) { ((System.Web.UI.HtmlControls.HtmlTextArea)x).Value = string.Empty; } FindHtmlInputText(x); } } }
///不分大小写替换(搜索结果列表关键字不分大小写飘红,类似谷哥哥)
public static string ReplaceIgnoreCase(string src, string pattern, string replacement) { return Replace(src, pattern, replacement, RegexOptions.IgnoreCase); } public static string Replace(string src, string pattern, string replacement, RegexOptions options) { Regex regex = new Regex(pattern, options | RegexOptions.Compiled); return regex.Replace(src, replacement); }
上述代码有删改,仅供参考学习交流之用
以上文章由本人收集整理进行撰写,版权归属博客园及本人。欢迎转载和引用,但必须在转载和引用的开头或来源标注博客名称和该篇文章的链接地址。