"Error loading Partial View script" while "return CurrentUmbracoPage()"
Hello People,
I´m a beginner at Umbraco, so right now I´m trying to create a simple Contact form, which I is almost complete, except by the validation data which I can´t return without the error:
using StoreMVC.Models; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Umbraco.Web;
namespace StoreMVC.Controllers { public class ContactController : Umbraco.Web.Mvc.SurfaceController { [ChildActionOnly] public ActionResult ContactUsForm() { var model = new ContactModel();
//In case you need to access the current node var currentNode = Umbraco.TypedContent(UmbracoContext.PageId.GetValueOrDefault());
return PartialView("ContactUsForm", model); }
[HttpPost] public ActionResult ContactUsForm(ContactModel model) { // server validation here TempData["ErrorMessage"] = "Error processing field ...";
if (ModelState.IsValid) { var currentNode = Umbraco.TypedContent(UmbracoContext.PageId.GetValueOrDefault());
var homeNode = currentNode;
var sendEmailsFrom = homeNode.GetPropertyValue("sendEmailsFrom") ?? model.Email; var sendEmailsTo = homeNode.GetPropertyValue("sendEmailsTo") ?? "[email protected]";
TempData["InfoMessage"] = "Your message has been successfully sent and we will be in touch soon...";
// Clear all the form fields ModelState.Clear(); model.Name = string.Empty; model.Phone = string.Empty; model.Email = string.Empty; model.Message = string.Empty;
//redirect to current page to clear the form return RedirectToCurrentUmbracoPage(); } catch (Exception ex) { TempData["ErrorMessage"] = ex.Message + ex.StackTrace; } }
return CurrentUmbracoPage();
} } }
Models/ContactModel.cs
using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web;
namespace StoreMVC.Models { public class ContactModel { [Required(ErrorMessage = "Name is required")] public string Name { get; set; }
[Required] public string Email { get; set; }
[Required] public string Phone { get; set; }
[Required] public string Message { get; set; } } }
"Error loading Partial View script" while "return CurrentUmbracoPage()"
Hello People,
I´m a beginner at Umbraco, so right now I´m trying to create a simple Contact form, which I is almost complete, except by the validation data which I can´t return without the error:
Error loading Partial View script (file: ~/Views/MacroPartials/ContactForm.cshtml)
I´ve been reading a lot about this thread, but still not sure what the problem is.
This is the code that I got:
MacroPartials/ContactForm.cshtml
Partials/ContactUsForm.cshtml
}
Controllers/ContactController.cs
Models/ContactModel.cs
Any help, would be really appreciated!
Regards
Hi, i have the same issue, if you know how to fix it, please let me know! kind regards
Pure guess:
It may not be able to find this view, try putting in the full path
is working on a reply...