Asp.net MVC源码分析--Model Validation(Client端)实现(1)(4)
来源:未知 责任编辑:责任编辑 发表时间:2013-11-26 22:14 点击:次
14 return results;
15 }
16
17 string fullName = ViewData.TemplateInfo.GetFullHtmlFieldName(name);
18 if (formContext.RenderedField(fullName)) {
19 return results;
20 }
21
22 formContext.RenderedField(fullName, true);
23
24 IEnumerable<ModelClientValidationRule> clientRules = ClientValidationRuleFactory(name, metadata);
25 bool renderedRules = false;
26
27 foreach (ModelClientValidationRule rule in clientRules) {
28 renderedRules = true;
29 string ruleName = "data-val-" + rule.ValidationType;
30
31 ValidateUnobtrusiveValidationRule(rule, results, ruleName);
32
33 results.Add(ruleName, HttpUtility.HtmlEncode(rule.ErrorMessage ?? String.Empty));
34 ruleName += "-";
35
36 foreach (var kvp in rule.ValidationParameters) {
37 results.Add(ruleName + kvp.Key, kvp.Value ?? String.Empty);
38 }
39 }
40
41 if (renderedRules) {
42 results.Add("data-val", "true");
43 }
44
45 return results;
46 }
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>