标签:public ram ret build val static mod message pre
public static class ModelStateExtensions { /// <summary> /// 获取model验证错误信息 /// </summary> /// <param name="controller"></param> /// <returns></returns> public static string ExpendErrors(this System.Web.Mvc.Controller controller) { StringBuilder strBuild = new StringBuilder(); foreach (var item in controller.ModelState.Values) { if (item.Errors.Count > 0) { int itemErrorCount = item.Errors.Count; for (int i = 0; i < itemErrorCount; i++) { strBuild.Append(item.Errors[i].ErrorMessage); strBuild.Append("<br/>"); } } } return strBuild.ToString(); } }
标签:public ram ret build val static mod message pre
原文地址:http://www.cnblogs.com/tangchun/p/7519832.html