Hi all,
I have a pop-up form as follows (which uses FancyBox to display a certain DIV in the DOM that is previously hidden and contains a Partial):
In my surface controller I have:
/// <summary>
/// For more information, see:
/// http://stackoverflow.com/questions/6282049/form-with-attachments-upload-and-email-sending
/// </summary>
/// <param name="model">The popup form model</param>
/// <returns>The ActionResult</returns>
public ActionResult HandleFormPost(PopupFormModel model)
{
try
{
if (ModelState.IsValid)
{
// Then good to submit.
var sb = new StringBuilder();
sb.AppendFormat("<p>Name: {0}</p>", model.Name);
sb.AppendFormat("<p>Email: {0}</p>", model.Email);
sb.AppendFormat("<p>{0}</p>", model.Message);
using (var client = new SmtpClient())
{
EnquiryType enquiryType = Enquiries.GetEnquiryByID(model.EnquiryType);
if (enquiryType != null)
{
var mail = new MailMessage();
mail.To.Add(enquiryType.EmailAddress);
mail.Subject = "Website Form Submission";
mail.Body = sb.ToString();
if (model.Attachment.HasFile())
{
var attachment = new Attachment(model.Attachment.InputStream, model.Attachment.FileName);
mail.Attachments.Add(attachment);
}
client.Send(mail);
return PartialView("Webtechy_Success");
}
return PartialView("Webtechy_Error");
}
}
return CurrentUmbracoPage(); // Not valid, there is something they need to fill in.
}
catch(Exception ex)
{
return PartialView("Webtechy_Error");
}
}
However, rather than just updating the contents of the pop-up box, it’s returning the Partial view taking up the whole page.
Any ideas greatly appreciated.
Regards,
Ben
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/72556-returning-a-partial-view-actionresult-handleformpost-contactmodel-model