Hi all, I'm just redoing a very simple MVC app found on a book and I have created my model
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MvcGuestbookRevised.Models
{
public class GuestbookEntry
{
public int Id { get; set; }
public string Name { get; set; }
public string Message { get; set; }
public DateTime DateAdded { get; set; }
}
}
then using Entity Framework, I created a controller called GuestbookEntryController with read/write actions and views. It's all OK but when I navigated to the create URL localhost:xxxx/GuestbookEntry/Create I have my input fields, but I wanted that "Message" to be a textarea and not an input field. How do I do that? I don't seem to be able to change it in the Create view as I thought I'd do because there is nothing to change in there, here it is:
@model MvcGuestbookRevised.Models.GuestbookEntry
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
<legend>GuestbookEntry</legend>
<div class="editor-label">
@Html.LabelFor(model => model.Name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Message)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Message)
@Html.ValidationMessageFor(model => model.Message)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.DateAdded)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.DateAdded)
@Html.ValidationMessageFor(model => model.DateAdded)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
Any idea? Or was the approach to use an Entity Framework controller wrong in the first place?
thanks