Modelstate errors and inputvalues displayed on all forms on the same page
Hi!
I have multiple forms on the same page that uses the same model with dataannotations, my problem is when im submitting one of the forms to a surfacecontroller and using "return CurrentUmbracoPage()" all forms on the page gets the entered values, it also displays the modelstate errors on all forms.
Is it a way around this?
Controller:
[ChildActionOnly]
public ActionResult Index()
{
return PartialView("_ContactForm", new ContactInput());
}
[HttpPost]
public ActionResult Submit(ContactInput model)
{
if (!ModelState.IsValid)
return CurrentUmbracoPage();
return RedirectToCurrentUmbracoPage();
}
Model:
public class ContactInput
{
[Required]
public string Name { get; set; }
[Required]
public string Email { get; set; }
}
Modelstate errors and inputvalues displayed on all forms on the same page
Hi! I have multiple forms on the same page that uses the same model with dataannotations, my problem is when im submitting one of the forms to a surfacecontroller and using "return CurrentUmbracoPage()" all forms on the page gets the entered values, it also displays the modelstate errors on all forms.
Is it a way around this?
Controller:
Model:
View:
Form:
I do know i can solve this using begin ajaxform but i want to use the normal post.
Thanks in advance!
Up ^
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.