I am trying out the Editor Template in MVC 3
My model class is
public class BookViewModel
{
public int Id { get; set; }
public string Name { get; set; }
[DataType(DataType.Text)]
public string Author { get; set; }
}
I have create a partial view for Editor template and put that in a EditorTemplates folder with name Text.cshtml. following is the partial view
@inherits System.Web.Mvc.WebViewPage<string>
<p> Write the name of author</p> @Html.TextBox(Model)
and I used @Html.EditorFor in the view page
<p> Name : @Html.EditorFor(model => model.Name)</p>
<p> Author</p> @Html.EditorFor(model => model.Author)
But when I run the program what I see is only an empty TextBox. I should see a TextBox filled with Author Name right?
What am I missing here?
Your editor template should be:
The first parameter of the @Html.TextBox() helper can be an empty string as well, but its not recommended