We have a "Comment about this page" link on the bottom of every page that opens a form that our constituents use to make comments about whatever pages they are viewing. The form emails our web authors with a page link and the message. I need to reproduce this functionality in EPiServer.
I hope I’m going about this the right way.
I’ve created a block controller called CommentAboutFormController with Name, Email and Message, and am calling this block as a property in SitePageData, since the form needs to be on every page.
public class CommentAboutForm : BlockData
{
[Display(Name = "Name")]
public virtual string name { get; set; }
[Display(Name = "Email")]
public virtual string email { get; set; }
[Display(Name = "message")]
public virtual string message { get; set; }
}
I created a SubmitComment action result in my default page controller which I'd like to use to send an email out to our web authors. Right now I’m just debugging to see if I can get form data to pull through. The form data should be in currentPage.CommentAbout, but it is null
[HttpPost]
public virtual ActionResult SubmitComment(SitePageData currentPage)
{
var returnURL = UrlResolver.Current.GetUrl(currentPage.ContentLink);
...
return Redirect(returnURL + "#Contact");
}
This is the form
@using (Html.BeginForm("SubmitComment", null))
{
* Your Name:
@Html.TextBoxFor(m => m.CurrentPage.CommentAbout.name, new { @class = "form-control", required = "required" })
@Html.ValidationMessageFor(x => x.CurrentPage.CommentAbout.name, "", new { @class = "red" })
URL are not allowed.
* Your Email:
@Html.TextBoxFor(m => m.CurrentPage.CommentAbout.email, new { @class = "form-control", type = "email", required = "required" })
@Html.ValidationMessageFor(x => x.CurrentPage.CommentAbout.email, "", new { @class = "red" })
* Comment:
@Html.TextAreaFor(m => m.CurrentPage.CommentAbout.message, new { @class = "form-control", @cols = 15, @rows = 5, required = "required" })
@Html.ValidationMessageFor(x => x.CurrentPage.CommentAbout.message, "", new { @class = "red" })
URL are not allowed.
}
When I hit submit, I can get the page data to pull through just fine, but the CommentAbout block is always coming though as Null.
Does anyone have any suggestions as to how I can get this form data to pull through? Or perhaps a better way for me to accomplish getting this form on every page?
We have a "Comment about this page" link on the bottom of every page that opens a form that our constituents use to make comments about whatever pages they are viewing. The form emails our web authors with a page link and the message. I need to reproduce this functionality in EPiServer.
I hope I’m going about this the right way.
I’ve created a block controller called CommentAboutFormController with Name, Email and Message, and am calling this block as a property in SitePageData, since the form needs to be on every page.
I created a SubmitComment action result in my default page controller which I'd like to use to send an email out to our web authors. Right now I’m just debugging to see if I can get form data to pull through. The form data should be in currentPage.CommentAbout, but it is null
This is the form
When I hit submit, I can get the page data to pull through just fine, but the CommentAbout block is always coming though as Null.
Does anyone have any suggestions as to how I can get this form data to pull through? Or perhaps a better way for me to accomplish getting this form on every page?