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


C# HtmlHelper.ValidationMessage方法代码示例

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


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

示例1: ValidationMessageWithNoErrorResultsInNullString

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

            // Act
            var html = htmlHelper.ValidationMessage("does-not-exist");

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

示例2: ValidationMessageReturnsWithCustomMessage

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

            // Atc
            var html = htmlHelper.ValidationMessage("foo", "bar error");

            // Assert
            Assert.AreEqual(@"<span class=""field-validation-error"">bar error</span>", html.ToHtmlString());
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:10,代码来源:ValidationHelperTest.cs

示例3: ValidationMessageReturnsWithObjectAttributes

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

            // Act
            var html = htmlHelper.ValidationMessage("foo", new { attr = "attr-value" });

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

示例4: ValidationMessageReturnsNullForInvalidName

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

            // Act
            var html = htmlHelper.ValidationMessage("baz");

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

示例5: ValidationMessageReturnsFirstError

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

            // Act 
            var html = htmlHelper.ValidationMessage("foo");

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

示例6: ValidationMessageAllowsEmptyModelName

        public void ValidationMessageAllowsEmptyModelName() {
            // Arrange
            ModelStateDictionary dictionary = new ModelStateDictionary();
            dictionary.AddError("test", "some error text");
            HtmlHelper htmlHelper = new HtmlHelper(dictionary);

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

            // Assert
            Assert.AreEqual(@"<span class=""field-validation-error"">some error text</span>", html.ToHtmlString());
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:12,代码来源:ValidationHelperTest.cs

示例7: ValidationMessageWithModelStateAndNoErrors

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

            // Act
            var html = htmlHelper.ValidationMessage("baz");

            // Assert
            Assert.IsNull(html, "html should be null if there are no errors");
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:10,代码来源:ValidationHelperTest.cs

示例8: ValidationMessageReturnsWithCustomMessageAndObjectAttributes

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

            // Act
            var html = htmlHelper.ValidationMessage("foo", "bar error", new { baz = "baz" });

            // Assert
            Assert.AreEqual(@"<span baz=""baz"" class=""field-validation-error"">bar error</span>", html.ToHtmlString());
        }
开发者ID:jesshaw,项目名称:ASP.NET-Mvc-3,代码行数:10,代码来源:ValidationHelperTest.cs


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