Client Side populated data was lost when returning to current umbraco page. CurrentUmbracoPage().
Hi,
I am developing a form using umbraco 7.2.4 and SurfaceController.
I have 3 list boxes defined in the view as follows:
@Html.ListBoxFor(m => m.occsectors, new SelectList(Model.occsectorList, "Value", "Text", Model.occsectors), new { @Id = "OccSectorsList", size = 8 })
@Html.ListBoxFor(m => m.occgroups, new SelectList(Model.occgroupList, "Value", "Text", Model.occgroups), new { @Id = "OccGroupList", size = 8 })
@Html.ListBoxFor(m => m.occupations, new SelectList(Model.occupationList, "Value", "Text", Model.occupations), new { @Id = "OccList", size = 8 })
The first list box "OccSectorsList" is populated in the controller by populating Model.occsectors
But the other two are populated on the client side using Ajax function and jQuery to populate the list box.
All working except when the model is invalid and returning to the form using CurrentUmbracoPage() from controller. The data of "OccGroupList" and "OccList" are lost. But, the first list box "OccSectorsList" retains its list and selected value.
We got the same problem.
If we populate a list inside the model in the view with JQuery. We would get the data in the SurfaceController. But loose it again if the model is not valid.
For the exsample we populated 2 items in the list.
@using (Html.BeginUmbracoForm<MemberController>("Submit"))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary()
@* The list contains zero submembers. (But it could) *@
@for (var i = 0; i < Model.SubMembers.Count; i++)
{
@Html.TextBoxFor(model => model.SubMembers[i].Name)
}
@* So we populate 2 here *@
<input id="SubMembers_0__Name" name="SubMembers[0].Name" type="text" value="Jens">
<input id="SubMembers_1__Name" name="SubMembers[1].Name" type="text" value="Per">
}
In the SurfaceController we would get these 2 populated submembers,
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Submit(MemberModel model)
{
// Contains 2. Contains Jens & Per
var listCount = model.SubMembers.Count;
if (!ModelState.IsValid)
{
// if the model is invalid. We loose the model.SubMembers in the view.
return CurrentUmbracoPage();
}
return RedirectToCurrentUmbracoPage();
}
Client Side populated data was lost when returning to current umbraco page. CurrentUmbracoPage().
Hi,
I am developing a form using umbraco 7.2.4 and SurfaceController.
I have 3 list boxes defined in the view as follows:
@Html.ListBoxFor(m => m.occsectors, new SelectList(Model.occsectorList, "Value", "Text", Model.occsectors), new { @Id = "OccSectorsList", size = 8 })
@Html.ListBoxFor(m => m.occgroups, new SelectList(Model.occgroupList, "Value", "Text", Model.occgroups), new { @Id = "OccGroupList", size = 8 })
@Html.ListBoxFor(m => m.occupations, new SelectList(Model.occupationList, "Value", "Text", Model.occupations), new { @Id = "OccList", size = 8 })
The first list box "OccSectorsList" is populated in the controller by populating Model.occsectors
But the other two are populated on the client side using Ajax function and jQuery to populate the list box.
All working except when the model is invalid and returning to the form using CurrentUmbracoPage() from controller. The data of "OccGroupList" and "OccList" are lost. But, the first list box "OccSectorsList" retains its list and selected value.
Anyone has any clue how to solve this?
Any updates on this?
We got the same problem. If we populate a list inside the model in the view with JQuery. We would get the data in the SurfaceController. But loose it again if the model is not valid.
For the exsample we populated 2 items in the list.
In the SurfaceController we would get these 2 populated submembers,
Any pointers would be appreciate ;)
is working on a reply...