- /// <summary>
- /// 转换HTML特殊字符为编码
- /// </summary>
- /// <param name="inputString">需要转换的字符串</param>
- /// <returns>已经转换的字符串</returns>
- public string ConvertInput(string inputString)
- {
- string retVal = inputString;
- retVal = retVal.Replace("&", "&");
- retVal = retVal.Replace("/"", """);
- retVal = retVal.Replace("'", """);
- retVal = retVal.Replace("<", "<");
- retVal = retVal.Replace(">", ">");
- retVal = retVal.Replace(" ", " ");
- retVal = retVal.Replace(" ", " ");
- retVal = retVal.Replace("/t", " ");
- retVal = retVal.Replace("/r/n", "<br/>");
- return retVal;
- }
- /// <summary>
- /// 验证是否有特殊字符
- /// </summary>
- /// <param name="inputString">需要验证的字符串</param>
- /// <returns>如果有特殊字符返回True</returns>
- public bool ValidateInput(string inputString)
- {
- bool blVaD=false;
- blVaD = inputString.Contains("&");
- blVaD = inputString.Contains("/"");
- blVaD = inputString.Contains("'");
- blVaD = inputString.Contains("<");
- blVaD = inputString.Contains(">");
- blVaD = inputString.Contains(" ");
- blVaD = inputString.Contains(" ");
- blVaD = inputString.Contains("/t");
- blVaD = inputString.Contains("/r/n");
- return blVaD;
- }