I want to make something like a questionnaire with different sections. Therefore, I created an Index.cshtml, which includes the according partial View (depending on the number my step-integer has). Something like
@using (Html.BeginForm())
{
@Html.Partial("Step" + Model.Step, Model)
<p>
@if (Model.Step > 1)
{
<button name="button" value="Zurück" />
}
<input type="submit" value="Weiter" />
</p>
}
As you may already noticed, It will look for something like "Step1.cshtml" and so on, where the according input mask is placed, for example
@model CVGen.Models.InputModel
<div class="editor-field">
@Html.TextBoxFor(model => model.Anrede)
@Html.ValidationMessageFor(model => model.Anrede)
</div>
My model contains the properties of the whole questionnaire, so of course I want to pass the whole model every time to the next step/view (and if I go back the model should be passed back too, so that the information is still there and the user can edit it). But it just won't work for me. My controller looks something like this:
public ActionResult Index()
{
InputModel model = new InputModel();
return View(model);
}
[HttpPost]
public ActionResult Index(InputModel model)
{
model.Step++;
return View(model);
}
Also my model.Step Property is always 0 (or 1, after 1 is added in the HttpPost), which is of course because my model won't be passed a second time.
Any suggestions?