zoukankan      html  css  js  c++  java
  • 工具类

    /// <summary>
            /// md5加密方式
            /// </summary>
            /// <param name="str">原字符串</param>
            /// <param name="code">16,32 位</param>
            /// <returns>加密后的字符串</returns>
            public static string MD5(string str, int code)
            {
                if (code == 16)
                {
                    return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "md5").ToLower().Substring(8, 16);
                }
                if (code == 32)
                {
                    return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(str, "md5").ToUpper();
                }
                return str;
            }
    
            // 返回指定字符串的值
    
            public static string TagVal(string Tag, string TagName)
            {
                string[] strArray = Tag.Split(new char[] { ',' });
                for (int i = 0; i < strArray.Length; i++)
                {
                    Regex regex = new Regex(@"(?<Keyword>w+)s*=s*(?<Value>.*)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
                    for (Match match = regex.Match(strArray[i]); match.Success; match = match.NextMatch())
                    {
                        if (match.Groups["Keyword"].ToString().ToLower().IndexOf(TagName.ToLower()) != -1)
                        {
                            return match.Groups["Value"].ToString();
                        }
                    }
                }
                return "";
            }
    
    
            /// <summary>
            /// 弹出消息框
            /// </summary>
            /// <param name="message">消息内容</param>
            public static void Alert(string message, System.Web.UI.Page page)
            {
                string js = "<script language=javascript>alert('{0}');</script>";
                if (!page.ClientScript.IsStartupScriptRegistered(page.GetType(), "AlertAndRedirect"))
                {
                    page.ClientScript.RegisterStartupScript(page.GetType(), "Alert", string.Format(js, message));
                }
            }
    
    
    
    
            /// <summary>
            /// 重写URL,分页函数
            /// </summary>
            /// <param name="RecordCount">记录总数</param>
            /// <param name="PageSize">分页大小</param>
            /// <param name="PageIndex">当前页</param>
            /// <param name="PageList">循环页码个数</param>
            /// <param name="strWhere">参数</param>
            /// <param name="cssClass">页面</param>
            /// <returns>分页字符串</returns>
            public static string GetPageListManage(string url, int RecordCount, int PageSize, int PageIndex, int PageList, string strWhere)
            {
                StringBuilder strPage = new StringBuilder();
                if (PageSize <= 0) PageSize = 1;
                int PageCount = (RecordCount + PageSize - 1) / PageSize;
                int PageTemp = 0;
                if (PageIndex > PageCount)
                {
                    PageIndex = PageCount;
                }
                else if (PageIndex <= 0)
                {
                    PageIndex = 1;
                }
    
                //新的分页
                strPage.AppendFormat("<div class="bigPage">");
                strPage.AppendFormat("<a href="" + url + "?page={0}" onfocus="this.blur()" class="previous" beginpage="1">上一页</a>", PageIndex - 1 <= 0 ? 1 : PageIndex - 1, strWhere);
                PageTemp = ((PageIndex - 1) / PageList) * PageList + 1;
                int i = 1;
                while (i <= PageList && PageTemp <= PageCount)
                {
                    i++;
                    strPage.AppendFormat(PageTemp == PageIndex ? "<a class="hover">{0}</a>" : "<a style='margin-left:5px;margin-right:5px;' href="" + url + "?page={0}" onfocus="this.blur()">{0}</a>", PageTemp++);
                }
    
                if (PageCount > 10)
                {
                    strPage.AppendFormat("<span>...</span>");
                }
    
                strPage.AppendFormat("<a href="" + url + "?page={0}" class="previous" onfocus="this.blur()">下一页</a>", PageIndex + 1 > PageCount ? PageCount : PageIndex + 1, strWhere);
                strPage.AppendFormat(" </div>");
                return strPage.ToString();
            }
    

      

  • 相关阅读:
    CEPH篇 CEPH接口(S3)
    MAC篇 超级简单的连接远程主机方法(永久记住)
    【思维论01】如何让自己像打王者荣耀一样发了疯、石乐志的学习?
    CEPH篇 CEPH部署(在线和离线 Centos 7)
    JAVA优化篇 如何从茫茫日志中找到运行缓慢的线程
    CEPH篇 块存储、文件存储和对象存储意义和差异
    CEPH篇 简介及关键对象解释
    混合使用Jquery Deferred和Angularjs的$timeout(转)
    AngularJs应用页面切换优化方案(转)
    在IE7下使用angularjs(转)
  • 原文地址:https://www.cnblogs.com/Aamir-Ye/p/4544379.html
Copyright © 2011-2022 走看看