Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7925057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:06:23+00:00 2026-06-03T18:06:23+00:00

I have an Index View, where I got a form containing a partial view

  • 0

I have an Index View, where I got a form containing a partial view for the different formulars.

@Html.ValidationSummary(true, "Beheben Sie die Fehler, und wiederholen Sie den Vorgang.")
@using (Html.BeginForm())
{
object mod = null;
switch (Model.Step)
{
    case 1:
        Html.RenderPartial("Step1", Model.Step1);
        break;
    case 2:
        Html.RenderPartial("Step2", Model.Step2);
        break;
    default:
        Html.RenderPartial("Step0");
        break;
}

<p>
    @if (Model.Step > 100000)
    {
        <button name="button" value="Zurück" />
    }
    @if (Model.Step != 0)
    {      
        <input type="submit" name="submit" value="Zurück" />   <input type="submit" name="submit"
            value="Weiter" id="Weiter" /> <input type="submit" name="submit" value="Abbrechen" />
    }
</p>
}

In my Controller I got something like this:

[HttpPost]
public ActionResult Index(InputModel model, string submit, HttpPostedFileBase file)
{
    if (String.IsNullOrEmpty(submit))
        submit = "";
    if (submit == "Weiter")
        model.Step++;

    if (submit == "Zurück")
        model.Step--;

The InputModel has several “sub-models” like this:

public Step1Model Step1 { get; set; }

public Step2Model Step2 { get; set; }

public Step3Model Step3 { get; set; }

Which are passed to the partial view to fill them.
The problem now is that I always get an empty model in my HttpPost in my controller.
What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T18:06:24+00:00Added an answer on June 3, 2026 at 6:06 pm

    What am I doing wrong?

    You are using partials. Partials don’t respect the navigational context. So when you look at your generated HTML source you will see the following:

    <input type="text" name="SomeProperty" value="some value" />
    

    instead of the correct one which is expected by the default model binder:

    <input type="text" name="Step1.SomeProperty" value="some value" />
    

    So when you submit this form you are not properly binding to the Step1 property. Same remark obviously for the other complex properties.

    One possibility is to use editor templates instead of partials because they preserve the navigational context and generate proper names for your input fields.

    So instead of:

    Html.RenderPartial("Step1", Model.Step1);
    

    use:

    @Html.EditorFor(x => x.Step1, "Step1")
    

    and then move your ~/Views/SomeController/Step1.cshtml partial to ~/Views/SomeController/EditorTemlpates/Step1.cshtml.

    If you don’t want to use editor templates but keep with the partials you could change the temlpate prefix inside the partial. So for example inside Step1.cshtml partial you could put the following in the top:

    @{
        ViewData.TemplateInfo.HtmlFieldPrefix = "Step1";
    }
    

    Now when you inspect your generated HTML source proper names should be emitted for the input fields. Personally I would recommend you the editor templates approach though to avoid hardcoding the prefix and making this partial less reusable compared to the editor templates.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my rails view(index.html.erb), i have following structure <div> <%= render :partial => create
I have the following code in my index view. latest_entry_list = Entry.objects.filter(is_published=True).order_by('-date_published')[:10] for entry
I have a view and template called index.html. I have a image which is
I have an index view that I want to update automatically as the user
If I have a HomeController displaying its Index view, how would I proceed in
I have a view in a Django 1.4 project: def index(request): print reverse('menus_index') latest_menu_list
I have the following view: @model MyModel1 @{ ViewBag.Title = Index; Layout = ~/Views/Shared/_Layout.cshtml;
I have a listbox (detailed view). How do I get the index of the
i am using php 5.2.8 i have index.html, which loads LOAD.PHP from IFRAME. iframe
I've got an MVC 3 form in a strongly typed view where one of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.