I am having issues trying to return back an invalid model when a page is using the Html.BeginUmbracoForm() which renders the encType attribute in order for me to upload files from the client.
My controller derives from SurfaceController.
My controller has the following actions:
public ActionResult UploadJobs() { var model = new UploadJobsModel();
return PartialView(model); }
[HttpPost] [ValidateAntiForgeryToken] public ActionResult UploadJobs(UploadJobsModelmodel) { if (!ModelState.IsValid) { return PartialView(model);
The problem is, when you POST back and the validation fails, I want to return back that model with validation errors. This works except that the whole page breaks where the css/javascript references are no longer being referenced and only just the partial view seems to be rendered.
However, on many other partial views I have done which do NOT use the BeginUmbracoForm and do not have a file upload control, it works fine.
I need this particular view to work so I can upload files and display any validation errors back to the view should there be any.
Issues with enctype for file upload
I am having issues trying to return back an invalid model when a page is using the Html.BeginUmbracoForm() which renders the encType attribute in order for me to upload files from the client.
My controller derives from SurfaceController.
My controller has the following actions:
public ActionResult UploadJobs()
{
var model = new UploadJobsModel();
return PartialView(model);
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult UploadJobs(UploadJobsModelmodel)
{
if (!ModelState.IsValid)
{
return PartialView(model);
}
// TODO: Processing.
return PartialView(model);
}
My view is like so:
@model UmbracoSite.Models.Jobs.UploadJobsModel
The problem is, when you POST back and the validation fails, I want to return back that model with validation errors. This works except that the whole page breaks where the css/javascript references are no longer being referenced and only just the partial view seems to be rendered.
However, on many other partial views I have done which do NOT use the BeginUmbracoForm and do not have a file upload control, it works fine.
I need this particular view to work so I can upload files and display any validation errors back to the view should there be any.
any thoughts? I am REALLY stuck.
Hi Ahmed, have you seen this post?
http://umbraco.com/follow-us/blog-archive/2013/7/14/moving-from-webforms-to-mvc.aspx
is working on a reply...