当前位置: 首页>>代码示例>>C#>>正文


C# HtmlHelper.ValidationSummary方法代码示例

本文整理汇总了C#中System.Web.WebPages.Html.HtmlHelper.ValidationSummary方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlHelper.ValidationSummary方法的具体用法?C# HtmlHelper.ValidationSummary怎么用?C# HtmlHelper.ValidationSummary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.WebPages.Html.HtmlHelper的用法示例。


在下文中一共展示了HtmlHelper.ValidationSummary方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValidationSummaryWithMultipleFormErrorsAndExcludedFieldErrors

        public void ValidationSummaryWithMultipleFormErrorsAndExcludedFieldErrors() {
            // Arrange
            ModelStateDictionary modelState = new ModelStateDictionary();
            modelState.AddFormError("error <1>");
            modelState.AddFormError("error <2>");

            HtmlHelper htmlHelper = new HtmlHelper(modelState);

            // Act
            var html = htmlHelper.ValidationSummary(excludeFieldErrors: true);

            // Assert
            Assert.AreEqual(@"<div class=""validation-summary-errors""><ul>
<li>error &lt;1&gt;</li>
<li>error &lt;2&gt;</li>
</ul></div>"
                , html.ToHtmlString());
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:18,代码来源:ValidationHelperTest.cs

示例2: ValidationSummaryWithNoErrorReturnsNull

        public void ValidationSummaryWithNoErrorReturnsNull() {
            // Arrange
            HtmlHelper htmlHelper = new HtmlHelper(new ModelStateDictionary());

            // Act
            var html = htmlHelper.ValidationSummary();

            // Assert
            Assert.IsNull(html);
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:10,代码来源:ValidationHelperTest.cs

示例3: ValidationSummaryWithNoFormErrorsAndExcludedFieldErrorsReturnsNull

        public void ValidationSummaryWithNoFormErrorsAndExcludedFieldErrorsReturnsNull() {
            // Arrange
            ModelStateDictionary modelState = new ModelStateDictionary();
            modelState.AddError("foo", "error");
            modelState.AddError("bar", "error");

            HtmlHelper htmlHelper = new HtmlHelper(modelState);

            // Act
            var html = htmlHelper.ValidationSummary(excludeFieldErrors: true);

            // Assert
            Assert.IsNull(html);
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:14,代码来源:ValidationHelperTest.cs

示例4: ValidationSummaryWithCustomValidationSummaryClass

        //[TestMethod]
        // Cant test this, as it sets a static property 
        public void ValidationSummaryWithCustomValidationSummaryClass() {
            // Arrange
            HtmlHelper.ValidationSummaryClass = "my-val-class";
            HtmlHelper htmlHelper = new HtmlHelper(GetModelStateWithErrors());

            // Act
            var html = htmlHelper.ValidationSummary("This is a message.", new Dictionary<string, object> { { "attr", "attr-value" }, { "class", "my-class" } });

            // Assert
            Assert.AreEqual(@"<div attr=""attr-value"" class=""my-val-class my-class""><span>This is a message.</span>
<ul>
<li>foo error &lt;1&gt;</li>
<li>foo error &lt;2&gt;</li>
<li>bar error &lt;1&gt;</li>
<li>bar error &lt;2&gt;</li>
</ul></div>"
                , html.ToHtmlString());
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:20,代码来源:ValidationHelperTest.cs

示例5: ValidationSummaryWithDictionary

        public void ValidationSummaryWithDictionary() {
            // Arrange
            HtmlHelper htmlHelper = new HtmlHelper(GetModelStateWithErrors());

            // Act
            var html = htmlHelper.ValidationSummary(new Dictionary<string, object> 
                { { "attr", "attr-value"} , { "class", "my-class" }} );

            // Assert
            Assert.AreEqual(@"<div attr=""attr-value"" class=""validation-summary-errors my-class""><ul>
<li>foo error &lt;1&gt;</li>
<li>foo error &lt;2&gt;</li>
<li>bar error &lt;1&gt;</li>
<li>bar error &lt;2&gt;</li>
</ul></div>"
                , html.ToHtmlString());
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:17,代码来源:ValidationHelperTest.cs

示例6: ValidationSummaryWithObjectProperties

        public void ValidationSummaryWithObjectProperties() {
            // Arrange
            HtmlHelper htmlHelper = new HtmlHelper(GetModelStateWithErrors());

            // Act
            var html = htmlHelper.ValidationSummary(new { attr = "attr-value", @class = "my-class" });

            // Assert
            Assert.AreEqual(@"<div attr=""attr-value"" class=""validation-summary-errors my-class""><ul>
<li>foo error &lt;1&gt;</li>
<li>foo error &lt;2&gt;</li>
<li>bar error &lt;1&gt;</li>
<li>bar error &lt;2&gt;</li>
</ul></div>"
                , html.ToHtmlString());
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:16,代码来源:ValidationHelperTest.cs

示例7: ValidationSummaryWithFormErrorsAndExcludeFieldErrors

        public void ValidationSummaryWithFormErrorsAndExcludeFieldErrors() {
            // Arrange
            HtmlHelper htmlHelper = new HtmlHelper(GetModelStateWithFormErrors());

            // Act
            var html = htmlHelper.ValidationSummary(excludeFieldErrors: true);

            // Assert
            Assert.AreEqual(@"<div class=""validation-summary-errors""><ul>
<li>some form error &lt;1&gt;</li>
<li>some form error &lt;2&gt;</li>
</ul></div>"
                , html.ToHtmlString());
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:14,代码来源:ValidationHelperTest.cs

示例8: ValidationSummaryWithMessage

        public void ValidationSummaryWithMessage() {
            // Arrange
            HtmlHelper htmlHelper = new HtmlHelper(GetModelStateWithErrors());

            // Act
            var html = htmlHelper.ValidationSummary("test message");

            // Assert
            Assert.AreEqual(@"<div class=""validation-summary-errors""><span>test message</span>
<ul>
<li>foo error &lt;1&gt;</li>
<li>foo error &lt;2&gt;</li>
<li>bar error &lt;1&gt;</li>
<li>bar error &lt;2&gt;</li>
</ul></div>"
                , html.ToHtmlString());
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:17,代码来源:ValidationHelperTest.cs


注:本文中的System.Web.WebPages.Html.HtmlHelper.ValidationSummary方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。