#region 获取超链接修改参数返回修改参数后的链接地址 /// <summary> /// 获取超链接修改参数返回修改参数后的链接地址 /// </summary> /// <param name="url">链接地址</param> /// <param name="changename">要修改的参数名</param> /// <param name="changevalue">修改的参数值</param> /// <returns>修改后的参数地址</returns> private string ReturnPage(Uri url,string changename,string changevalue) { string strUrlReferrer = url.ToString(); string strUrl = null, strTemp = null; string str = ""; if (strUrlReferrer.IndexOf("?") == -1) { strUrl = strUrlReferrer; } else if (strUrlReferrer.IndexOf("?") > 0) { strUrl = strUrlReferrer.Substring(0, strUrlReferrer.IndexOf("?")); strTemp = strUrlReferrer.Substring(strUrlReferrer.IndexOf("?") + 1, strUrlReferrer.Length - strUrlReferrer.IndexOf("?") - 1); if (strTemp.IndexOf("&") == -1) { string[] strParam = strTemp.Split('='); if (strParam[0].ToString().Trim().ToUpper() == changename) { str += changename + "=" + changevalue; } else { str += strParam[0] + "=" + strParam[1].ToString()+"&"+changename+"="+Server.UrlEncode(changevalue); } } else { string[] strParamCount = strTemp.Split('&'); for (int k = 0; k < strParamCount.Length; k++) { if (k > 0 && k < strParamCount.Length) { if (strParamCount[k].ToString().Trim().ToUpper().IndexOf(changename) > -1) { str += "&"+changename+"="+changevalue+""; } else { string[] strParam = strParamCount[k].Split('='); str += "&" + strParam[0] + "=" + Server.UrlEncode(strParam[1]); } } else if (k == 0) { if (strParamCount[k].ToString().Trim().ToUpper().IndexOf(changename) > -1) { str += changename+"="+changevalue; } else { string[] strParam = strParamCount[k].Split('='); str += strParam[0] + "=" + Server.UrlEncode(strParam[1]); } } } } } return strUrl + "?" + str; } #endregion