Changing the size of Html.TextBox

后端 未结 2 757
梦如初夏
梦如初夏 2021-01-27 03:58

I\'m developing an ASP.NET MVC3 application using the new Razor view engine but I\'m having some difficulty changing a TextBox so that it is multiline. So far all I\'ve been ab

相关标签:
2条回答
  • 2021-01-27 04:33

    You could decorate the Body property on your view model with the [DataType] attribute:

    [DataType(DataType.MultilineText)]
    public string Body { get; set; }
    

    and in your view use the EditorFor helper instead of TextBoxFor:

    <div class="editor-field">
        @Html.EditorFor(model => model.Body)
    </div>
    

    Another possibility is to leave the model as is without adding any attributes to it and in your view use the TextAreaFor helper:

    <div class="editor-field">
        @Html.TextAreaFor(x => x.Body)
    </div>
    

    Personally I prefer the first approach.

    0 讨论(0)
  • 2021-01-27 04:46

    This is how to curve the corners of the textbox in asp.net mvc4:

    @HTML.TextBoxFor(Model => Model.Name)
    
    0 讨论(0)
提交回复
热议问题