1

i have two class as below

Model:-  

     public class RegisterViewModel
        {
             public string Email { get; set; }     
             public AddressPropertyVM AddressProperty { get; set; }
        }

        public class AddressPropertyVM
        {
             public string StreetNo { get; set; }     
        }
Main Form
@model Application.Models.RegisterViewModel
{
    @Html.TextBoxFor(m => m.Email)
    @Html.TextBoxFor(m => m.FirstName)

    @Html.Partial("_AddressPropertyPartial",Model.AddressProperty)

    <button type="submit">Register</button>

}

Partial View Form
@model Application.Models.AddressPropertyVM
{
    @Html.TextBoxFor(m => m.StreetNo)

}

I am creating asp.net mvc application.

I have create a partial view for AddressPropertyVM.

but we i post form(main form) at that time data of AddressProperty is null.

2
  • can you show the view ? Commented Mar 24, 2017 at 13:32
  • My view like this Commented Mar 24, 2017 at 13:39

1 Answer 1

3

As per my understanding you want to use one partial view with more than one pages I mean multiple usage of one page in many pages.

Read this article and understand how it works.

Change your code as per article like below.

@Html.Partial("_AddressPropertyPartial",Model.AddressProperty)

To

@Html.Partial("_AddressPropertyPartial", Model.AddressProperty,  new ViewDataDictionary()   {     TemplateInfo = new TemplateInfo()       { HtmlFieldPrefix = "AddressProperty" } }
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.