Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In ASP.NET MVC 2, how do I get Html.TextBoxFor to render a textarea instead of an input tag?

This code:

<%: Html.TextBoxFor(model => model.DonationMessage) %>

Renders an input type=text tag, but I want a textarea. I tried this in my entity but it didn't make a difference:

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

Any idea?

like image 764
Chris Avatar asked Jul 10 '10 19:07

Chris


2 Answers

<%: Html.TextAreaFor(model => model.DonationMessage) %>
like image 76
Chase Florell Avatar answered Sep 27 '22 19:09

Chase Florell


if u want your DataType attribute to be at work you can use EdiotrFor method instead

<%: Html.EditorFor(model => model.DonationMessage) %>

this will take into account your DataType attribute plus there are dozen other things that you can do with Editor Templates

like image 24
Muhammad Adeel Zahid Avatar answered Sep 27 '22 20:09

Muhammad Adeel Zahid