/// <summary> /// 通过给定参数生成分页html /// </summary> /// <param name="url"></param> /// <param name="pageKey"></param> /// <param name="urlParams"></param> /// <param name="itemCount"></param> /// <param name="page"></param> /// <param name="pageSize"></param> /// <returns></returns> public static string GetPagerHtmlByData( string url, string pageKey, Dictionary <string, string> urlParams, int itemCount, int page, int pageSize) { url = ConvertHelper.GetString(url).Trim(); if (!url.EndsWith("?")) { url += "?"; } if (!ValidateHelper.IsPlumpString(pageKey)) { pageKey = "page"; } url += Com.DictToUrlParams(urlParams); if (ValidateHelper.IsPlumpDict(urlParams)) { url += "&"; } url += pageKey + "={0}"; int pageCount = GetPageCount(itemCount, pageSize); return(GetPagerHtml(page, pageCount, url)); }
/// <summary> /// 字典变url格式(a=1&b=3) /// </summary> public static string DictToUrlParams(IDictionary <string, string> data) { if (!ValidateHelper.IsPlumpDict(data)) { return(string.Empty); } var arr = data.Keys.Select(x => $"{x}={ConvertHelper.GetString(data[x])}"); return(string.Join("&", arr)); }