Hello I have recently began work on a largely JQuery/JQueryUI based ASP .Net website. The idea was to have only one page and to have the rest of the content be dynamic, etc loaded in through dialogs and ajax.
The problem is however when a Create & a Edit form for the same model are open in dialogs at the same time some JQueryUI widgets such as the DatePicker stop working as the forms cause the DOM to have duplicate id's on the fields which are present in both.
So I tried using this code on the controller:
ViewData.TemplateInfo.HtmlFieldPrefix = "Create"; // or Edit etc
This worked to fix the DatePicker problem, but the fields no longer mapped to the model when they were posted back to the controller.
Does anyone know how to fix this?
You could try specifying the same prefix when binding back:
[HttpPost]
public ActionResult Create([Bind(Prefix = "Create")] CreateViewModel model)
{
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With