I am using asp.net mvc to do model binding. When I pass a model to a view I am able to see the model data displayed in the form inside a label
<%= Html.Label(Model.title) %>
<%= Html.Label(Model.description) %>
However I am not able to do the same using
<%= Html.TextArea(Model.description)%>
Is there a syntax difference between displaying in a label as oppsed to a textbox?
Here is my view
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<EditDocumentViewData>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Update
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent"
<h2>Update</h2>
<form id="myForm" action="<%=Url.Action("Update") %>" method="post" >
<% Html.EnableClientValidation(); %>
<div id="validationSummary"><%= Html.ValidationSummary() %> </div>
<%= Html.ClientSideValidation(typeof(Document))
.UseValidationSummary("validationSummary") %>
<div style="float:left">
<input type="button" class="btnpost" id="btnMain" value="Main Thumb"/>
<input id="btnDelete" class="btnpost" type="button" value="Delete"/>
<br /> <br /> <br />
<br /> <br /> <br /> <br />
<table>
<%= Html.HiddenFor(m => m.id)%>
<tr> <td> <%=Html.Label("Title")%></td><td>
<%=Html.TextBox("title", Model.title)%>
</td> </tr>
<tr> <td> <%=Html.Label("Description")%></td><td>
<%= Html.TextArea("description", Model.description)%>
</td>
<td>
<%= Html.ValidationMessage("description")%>
</td>
</tr><tr><td> <%=Html.Label("Summary")%></td><td>
<%= Html.TextAreaFor(m=>m.summary)%>
</td> <td>
<%= Html.ValidationMessage("summary")%>
</td></tr>
</form>
</asp:Content>
my contollers actions are
[AcceptVerbs(HttpVerbs.Get)]
public ViewResult Update(int Id)
{
Document doc= _documentRepository.GetById(Id);
EditDocumentViewData documentViewData=new EditDocumentViewData();
documentViewData.id = doc.document_id;
documentViewData.category = doc.Category1.name;
documentViewData.title = doc.title;
documentViewData.Thumbs = doc.Thumbs.ToList();
documentViewData.description = doc.description;
documentViewData.summary = doc.summary;
return View(documentViewData);
// TempData["docid"] = doc.document_id;
//if (doc != null)
// return View(doc);
//else
// return View("Index");
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Update(EditDocumentViewData editDoc)
{
Document doc= _documentRepository.GetById(editDoc.id);
doc.title = editDoc.title;
doc.description = editDoc.description;
doc.summary = editDoc.summary;
_unitOfWorkManager.Commit();
return RedirectToAction("Index");
}