I have a model as order inside it I have a another object which I am trying to use in @Html.Partial Code snippet
public class Order{
public string Id{set;get
The reason for that is because the Partial is not respecting the naming convention for the input fields. Use an editor template instead:
@model Order
OrderId:
@Html.TextBoxFor(x => x.Id)
ShippingAdress:
@Html.EditorFor(x => x.ShippingAdress)
BillingAddress:
@Html.EditorFor(x => x.BillingAdress)
Now move your Adress.cshtml
to ~/Views/Shared/EditorTemplates/Address.cshtml
. The name and location of the template is important. It should be located in ~/Views/Shared/EditorTemplates
and named the same way as the model type (Address.cshtml
):
@model Address
...