摘要: View Code 1 #region 将字符串转换为数组 2 public static string[] GetStrArray(string str) 3 { 4 return str.Split(new char[',']); 5 } 6 #endregion 7 8 #region 将数组转换为字符串 9 public static string GetArrayStr(List<string> list, string speater)... 阅读全文
posted @ 2012-01-29 14:27 名字随意 阅读(187) 评论(0) 推荐(1) 编辑
摘要: View Code 1 /// <summary> 2 /// 字符串是否为空 3 /// </summary> 4 /// <param name="str"></param> 5 /// <returns></returns> 6 public static bool IsNullOrEmpty(this string str) 7 { 8 return str == null || str == string.Empty || str == ""; 9 } 10 11 /// 阅读全文
posted @ 2012-01-29 14:26 名字随意 阅读(144) 评论(0) 推荐(0) 编辑
摘要: View Code 1 /// <summary> 2 /// 防注入 3 /// </summary> 4 /// <param name="content">提交的内容</param> 5 /// <returns></returns> 6 public static string PreventScriptIncludeSQL(this string content) 7 { 8 int i = 0; 9 string sqlchar = "insertinto|deletefrom|a 阅读全文
posted @ 2012-01-29 14:25 名字随意 阅读(200) 评论(0) 推荐(0) 编辑
摘要: View Code 1 /// <summary> 2 /// 对象转化为字符串 3 /// </summary> 4 /// <param name="obj">对象</param> 5 /// <param name="defaultValue">默认值</param> 6 /// <returns></returns> 7 public static string GetString(this object obj) 8 { 9 return obj.T 阅读全文
posted @ 2012-01-29 14:23 名字随意 阅读(156) 评论(0) 推荐(0) 编辑
摘要: View Code 1 /// <summary> 2 /// 将DataRow读取到的一行 转为 Model 3 /// </summary> 4 /// <param name="dr">DataRow</param> 5 /// <returns>泛型实体</returns> 6 public static T ToModel(DataRow dr) 7 { 8 // 获得此模型的类型 9 Type type = typeof(T);10 string tempName = "" 阅读全文
posted @ 2012-01-29 14:22 名字随意 阅读(228) 评论(0) 推荐(0) 编辑
摘要: View Code 1 /// <summary> 2 /// 将 SqlDataReader 转为Model, 如果 SqlDataReader.read() 有值 ,返回对象,否则返回Null 3 /// </summary> 4 /// <param name="dr">SqlDataReader</param> 5 /// <returns>泛型实体</returns> 6 public static T ToModel(SqlDataReader dr) 7 { 8 // 获得此模型的类型 9 阅读全文
posted @ 2012-01-29 14:22 名字随意 阅读(269) 评论(0) 推荐(0) 编辑
摘要: View Code 1 /// <summary> 2 /// 将SqlDataReader读取的内容转为Model,结束后不会自动关闭Reader 3 /// </summary> 4 /// <param name="dr">SqlDataReader</param> 5 /// <returns>泛型实体集合</returns> 6 public static IList<T> ToModels(SqlDataReader dr) 7 { 8 IList<T> ts = n 阅读全文
posted @ 2012-01-29 14:21 名字随意 阅读(165) 评论(0) 推荐(0) 编辑
摘要: View Code 1 /// <summary> 2 /// 将DataTable转为Model 3 /// </summary> 4 /// <param name="dt">DataTable</param> 5 /// <returns>泛型实体集合</returns> 6 public static IList<T> ToModels(DataTable dt) 7 { 8 IList<T> ts = new List<T>(); 9 // 获得此模型的类型 阅读全文
posted @ 2012-01-29 14:20 名字随意 阅读(184) 评论(0) 推荐(0) 编辑
摘要: /// <summary> /// 关闭当前窗口并且返回值 /// </summary> public static void CloseWindowReturnValues(string value) { #region System.Text.StringBuilder Str = new System.Text.StringBuilder(); Str.Append("<Script language='JavaScript'type=\"text/javascrip... 阅读全文
posted @ 2012-01-29 10:16 名字随意 阅读(177) 评论(0) 推荐(0) 编辑
摘要: /// <summary> /// 打开指定大小的新窗体 /// </summary> /// <param name="url">地址</param> /// <param name="width">宽</param> /// <param name="heigth">高</param> /// <param name="top">头位置</param> /// <param name=& 阅读全文
posted @ 2012-01-29 10:13 名字随意 阅读(108) 评论(0) 推荐(0) 编辑
摘要: /// <summary> /// 转向Url制定的页面 /// </summary> /// <param name="url">连接地址</param> public static void JavaScriptLocationHref(string url) { #region string js = @"<Script language='JavaScript'> window.location.replace('{0}'); ... 阅读全文
posted @ 2012-01-29 10:13 名字随意 阅读(129) 评论(0) 推荐(0) 编辑
摘要: /// <summary> /// 刷新打开窗口 /// </summary> public static void RefreshOpener() { #region string js = @"<Script language='JavaScript'> opener.location.reload(); </Script>"; HttpContext.Current.Response.Write(... 阅读全文
posted @ 2012-01-29 10:10 名字随意 阅读(139) 评论(0) 推荐(0) 编辑
摘要: View Code 1 /// <summary> 2 /// 刷新父窗口 3 /// </summary> 4 public static void RefreshParent(string url) 5 { 6 #region 7 string js = @"<Script language='JavaScript'> 8 window.opener.location.href='" + url + "';window.close();</Script>"; 9 ... 阅读全文
posted @ 2012-01-29 10:09 名字随意 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 1 /// <summary> 2 /// 关闭当前窗口 3 /// </summary> 4 public static void CloseWindow() 5 { 6 #region 7 string js = @"<Script language='JavaScript'> 8 parent.opener=null;window.close(); 9 </Script>";10 HttpContext.... 阅读全文
posted @ 2012-01-29 10:08 名字随意 阅读(116) 评论(0) 推荐(0) 编辑
摘要: View Code 1 /// <summary> 2 /// 回到历史页面 3 /// </summary> 4 /// <param name="value">-1/1</param> 5 public static void GoHistory(int value) 6 { 7 #region 8 string js = @"<Script language='JavaScript'> 9 history.go({0}); 10 ... 阅读全文
posted @ 2012-01-29 10:05 名字随意 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 1 /// <summary> 2 /// 弹出消息框并且转向到上/下页 3 /// </summary> 4 /// <param name="message">消息内容</param> 5 /// <param name="value">-1/1</param> 6 public static void AlertAndRedirect(string message, int value) 7 { 8 #region 9 string js = "<script 阅读全文
posted @ 2012-01-29 10:04 名字随意 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 1 /// <summary> 2 /// 弹出消息框并且转向到新的URL 3 /// </summary> 4 /// <param name="message">消息内容</param> 5 /// <param name="toURL">连接地址</param> 6 public static void AlertAndRedirect(string message, string toURL) 7 { 8 #region 9 string js = "<scr 阅读全文
posted @ 2012-01-29 10:00 名字随意 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 1 /// <summary> 2 /// 把枚举转化为下拉选项 3 /// </summary> 4 /// <param name="ddl">引用参数:DropDownList</param> 5 /// <param name="enumType">枚举的类型</param> 6 /// <param name="isAddSelected">是否添加选择项</param> 7 public static void EnumToDr 阅读全文
posted @ 2012-01-29 09:59 名字随意 阅读(240) 评论(0) 推荐(0) 编辑
摘要: 1 /// <summary> 2 /// 获取客户端IP 3 /// </summary> 4 public static string GetClientIP() 5 { 6 string userIP; 7 if (HttpContext.Current.Request.ServerVariables["HTTP_VIA"] == null) 8 { 9 userIP = HttpContext.Current.Request.UserHostAddr... 阅读全文
posted @ 2012-01-29 09:57 名字随意 阅读(151) 评论(0) 推荐(0) 编辑
摘要: View Code 1 /// <summary> 2 /// 判断两个数组是否相等(顺序必须相同) 3 /// </summary> 4 /// <param name="a">数据A</param> 5 /// <param name="b">数据B</param> 6 /// <returns></returns> 7 public static bool ArrayIsEqual(String[] a, String[] b) 8 { 9 if (a 阅读全文
posted @ 2012-01-29 09:55 名字随意 阅读(468) 评论(0) 推荐(0) 编辑