I have the following class models in ASP.net MVC 3:
public class Application
{
public int Id { get; set; }
public DateTime CreatedOn { get; set; }
public BusinessBaseData Bbd { get; set; }
}
public class BusinessBaseDa开发者_运维知识库ta
{
public int Id { get; set; }
public string Name { get; set; }
public EconomicSector { get; set }
}
When I use Visual Studio 2010 to create a Edit view, and therefore asking for code scaffolding, I get a HTML TextBox for the CreatedOn field, but not for the BusinessBaseData Name and EconomicSector fields.
I want to automatically generate code for one-to-one relationships, and make that code available on the base class edit page. Should I use partials, or is there a cleaner way?
Thank you very much, Bruno
EDIT:
@hunter, here is the code I get (I'm using Razor Engine):
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset>
@*<legend>Fields</legend>*@
<div class="editor-label">
@Html.LabelFor(model => model.CreatedOn)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.CreatedOn)
@Html.ValidationMessageFor(model => model.CreatedOn)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
Thanks!
精彩评论