本文整理汇总了C#中System.Web.WebPages.Html.HtmlHelper.TextArea方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlHelper.TextArea方法的具体用法?C# HtmlHelper.TextArea怎么用?C# HtmlHelper.TextArea使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.WebPages.Html.HtmlHelper
的用法示例。
在下文中一共展示了HtmlHelper.TextArea方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TextAreaWithEmptyNameThrows
public void TextAreaWithEmptyNameThrows() {
// Arrange
HtmlHelper helper = new HtmlHelper(new ModelStateDictionary());
// Act and assert
ExceptionAssert.ThrowsArgumentException(() => helper.TextArea(null), "name", "Value cannot be null or an empty string.");
// Act and assert
ExceptionAssert.ThrowsArgumentException(() => helper.TextArea(String.Empty), "name", "Value cannot be null or an empty string.");
}
示例2: TextAreaWithNonZeroRowsAndColumns
public void TextAreaWithNonZeroRowsAndColumns() {
// Arrange
HtmlHelper helper = new HtmlHelper(new ModelStateDictionary());
// Act
var html = helper.TextArea("foo", null, 4, 10, null);
// Assert
Assert.AreEqual(@"<textarea cols=""10"" id=""foo"" name=""foo"" rows=""4""></textarea>", html.ToHtmlString());
}
示例3: TextAreaWithDefaultRowsAndCols
public void TextAreaWithDefaultRowsAndCols() {
// Arrange
HtmlHelper helper = new HtmlHelper(new ModelStateDictionary());
// Act
var html = helper.TextArea("foo");
// Assert
Assert.AreEqual(@"<textarea cols=""20"" id=""foo"" name=""foo"" rows=""2""></textarea>", html.ToHtmlString());
}
示例4: TextAreaWithObjectAttributes
public void TextAreaWithObjectAttributes() {
// Arrange
ModelStateDictionary modelState = new ModelStateDictionary();
modelState.SetModelValue("foo", "foo-value");
HtmlHelper helper = new HtmlHelper(modelState);
// Act
var html = helper.TextArea("foo", new { attr = "value", cols = 6 });
// Assert
Assert.AreEqual(@"<textarea attr=""value"" cols=""6"" id=""foo"" name=""foo"" rows=""2"">foo-value</textarea>", html.ToHtmlString());
}
示例5: TextAreaWithDictionaryAttributes
public void TextAreaWithDictionaryAttributes() {
// Arrange
ModelStateDictionary modelState = new ModelStateDictionary();
modelState.SetModelValue("foo", "explicit-foo-value");
HtmlHelper helper = new HtmlHelper(modelState);
var attributes = new Dictionary<string, object>() { { "attr", "attr-val" }, { "rows", 15 }, { "cols", 12 } };
// Act
var html = helper.TextArea("foo", attributes);
// Assert
Assert.AreEqual(@"<textarea attr=""attr-val"" cols=""12"" id=""foo"" name=""foo"" rows=""15"">explicit-foo-value</textarea>",
html.ToHtmlString());
}
示例6: TextAreaWithCustomErrorClass
// [TestMethod]
// Cant test this in multi-threaded
public void TextAreaWithCustomErrorClass() {
// Arrange
ModelStateDictionary modelState = new ModelStateDictionary();
modelState.AddError("foo", "some error");
HtmlHelper.ValidationInputCssClassName = "custom-field-validation-error";
HtmlHelper helper = new HtmlHelper(modelState);
// Act
var html = helper.TextArea("foo", String.Empty, new { @class = "my-css" });
// Assert
Assert.AreEqual(@"<textarea class=""custom-field-validation-error my-css"" cols=""20"" id=""foo"" name=""foo"" rows=""2""></textarea>",
html.ToHtmlString());
}
示例7: TextAreaWithError
public void TextAreaWithError() {
// Arrange
ModelStateDictionary modelState = new ModelStateDictionary();
modelState.AddError("foo", "some error");
HtmlHelper helper = new HtmlHelper(modelState);
// Act
var html = helper.TextArea("foo", String.Empty);
// Assert
Assert.AreEqual(@"<textarea class=""field-validation-error"" cols=""20"" id=""foo"" name=""foo"" rows=""2""></textarea>",
html.ToHtmlString());
}
示例8: TextAreaWithNoValueAndObjectAttributes
public void TextAreaWithNoValueAndObjectAttributes() {
// Arrange
HtmlHelper helper = new HtmlHelper(new ModelStateDictionary());
var attributes = new Dictionary<string, object>() { { "attr", "attr-val" }, { "rows", 15 }, { "cols", 12 } };
// Act
var html = helper.TextArea("foo", attributes);
// Assert
Assert.AreEqual(@"<textarea attr=""attr-val"" cols=""12"" id=""foo"" name=""foo"" rows=""15""></textarea>",
html.ToHtmlString());
}