After you saw your question, I study Google to find out what the problem of the extra line in @Html.TextAreaFor . Take a look.
There are several articles that are related to your problem: -
http://www.peschuster.de/2011/11/new-line-bug-in-asp-net-mvcs-textarea-helper/
ASP.NET MVC Textarea HTML Helper Adding Strings When Using AntiXssLibrary
The articles suggested the main problem in the TextAreaHelper class, which is used by @Html.TextAreaFor .
private static MvcHtmlString TextAreaHelper(HtmlHelper htmlHelper, ModelMetadata modelMetadata, string name, IDictionary<string, object> rowsAndColumns, IDictionary<string, object> htmlAttributes) {
and the problem is in the above code
tagBuilder.SetInnerText(Environment.NewLine + attemptedValue);
So, the actual output of @Html.TextAreaFor will be like this and an extra line will appear: -
<textarea>&
The workaround for this problem is
1st solution Implementation of the Javascript onLoad patch to remove encoding that violates all text areas:
$("textarea").each(function () { $(this).val($(this).val().trim()); });
2nd workaround: create your own helper for rendering textarea markup in views
public static MvcHtmlString FixedTextAreaFor<TModel, TProperty>( this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression) { return new MvcHtmlString(htmlHelper.TextAreaFor(expression) .ToHtmlString() .Replace("> ", ">" + Environment.NewLine)); }
These articles also suggested that this issue would be fixed in MVC 4 Developer Preview!