ive created a basic contact form in umbraco and the when the form page is created, a property (emailaddresses) is populated to list the recepients of that form.
i want to access that property within the controller as this is where the form contents are emailed out (to the email addesses listed in this property)....
the controller is called from a partial view and simply accesses the model properties before sending out an email...
can i access this property in my controller or would i pass it to the controller from my partial view ?
PARTIAL VIEW
@model UmbracoSite.Models.ContactModel
@using (Html.BeginUmbracoForm("Contact", "ContactSurface", null, new {@class = "contact-form"})) { @Html.ValidationSummary(false)
Accessing page property in a controller
ive created a basic contact form in umbraco and the when the form page is created, a property (emailaddresses) is populated to list the recepients of that form.
i want to access that property within the controller as this is where the form contents are emailed out (to the email addesses listed in this property)....
the controller is called from a partial view and simply accesses the model properties before sending out an email...
can i access this property in my controller or would i pass it to the controller from my partial view ?
PARTIAL VIEW
@model UmbracoSite.Models.ContactModel
@using (Html.BeginUmbracoForm("Contact", "ContactSurface", null, new {@class = "contact-form"}))
{
@Html.ValidationSummary(false)
<div>
@Html.LabelFor(x => x.Name)
@Html.TextBoxFor(x => x.Name)
@*@Html.ValidationMessageFor(x => x.Name)*@
</div>
<div>
@Html.LabelFor(x => x.Email)
@Html.TextBoxFor(x => x.Email)
@*@Html.ValidationMessageFor(x => x.Email)*@
</div>
<div>
@Html.LabelFor(x => x.Phone)
@Html.TextBoxFor(x => x.Phone)
@*@Html.ValidationMessageFor(x => x.Phone)*@
</div>
<div>
@Html.LabelFor(x => x.Subject)
@Html.TextBoxFor(x => x.Subject)
</div>
<div>
@Html.LabelFor(x => x.Message)
@Html.TextAreaFor(x => x.Message)
@*@Html.ValidationMessageFor(x => x.Message)*@
</div>
@Html.HiddenFor(x => x.ThankYouPage)
<input type="submit" value="Submit" />
}
CONTROLLER
public class ContactSurfaceController : SurfaceController
{
[HttpPost]
public ActionResult Contact(ContactModel model)
{
if (ModelState.IsValid)
{
var sb = new StringBuilder();
sb.AppendFormat("<p>Name: {0}</p>", model.Name);
sb.AppendFormat("<p>Email: {0}</p>", model.Email);
sb.AppendFormat("<p>Phone: {0}</p>", model.Phone);
sb.AppendFormat("<p>Message: {0}</p>", model.Message);
library.SendMail("email from", "emails to send to as set in page property", model.Subject, sb.ToString(), true);
return RedirectToUmbracoPage(model.ThankYouPage);
}
return CurrentUmbracoPage();
}
}
is working on a reply...