I have a form that i can add using Rich Text Editor via Macro,
i want to include CurrentPage.Name as hidden value that is passed on submit
what would be the syntax for it?
something like
@{
var currentPageName = CurrentPage.Name;
}
@HtmlHiddenFor(???, currentPageName??)
here is working code i have currently without passing hiddenvalue
Partial
@model Pro_Ghetto_Events.Models.FormEventPageModel
@{
}
@if (TempData["success"] == null)
{
using (Html.BeginUmbracoForm("Submit", "FormEventPage", new { enctype = "multipart/form-data" }))
{
<div class="small-12 medium-6 columns">
@Html.LabelFor(x => x.Name)
@Html.TextBoxFor(x => x.Name)
@Html.ValidationMessageFor(x => x.Name, "", new { @class = "error" })
</div>
<div class="small-12 medium-6 columns">
@Html.LabelFor(x => x.Email)
@Html.TextBoxFor(x => x.Email)
@Html.ValidationMessageFor(x => x.Email, "", new { @class = "error" })
</div>
<div class="small-12 medium-6 columns">
@Html.LabelFor(x => x.Phone)
@Html.TextBoxFor(x => x.Phone)
@Html.ValidationMessageFor(x => x.Phone)
</div>
<div class="small-12 medium-6 columns">
@Html.LabelFor(x => x.NumberOfGuests)
@Html.TextBoxFor(x => x.NumberOfGuests)
@Html.ValidationMessageFor(x => x.NumberOfGuests)
</div>
<div class="small-12 columns">
@Html.LabelFor(x => x.NeedTickets)
@Html.CheckBoxFor(x => x.NeedTickets)
</div>
<div class="small-12 columns" style="margin-top:15px;">
<input type="submit" value="Submit" class="button radius" />
</div>
}
}
else
{
<section class="lead">
<p>Thank you for your request</p>
<p>We have received your message and would like to thank you for writing to us.</p>
</section>
}
Model
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;
namespace Pro_Ghetto_Events.Models
{
public class FormEventPageModel
{
[Required]
public string Name { get; set; }
[Required]
[EmailAddress]
public string Email { get; set; }
public string Phone { get; set; }
[DisplayName("Number Of Guests")]
public string NumberOfGuests { get; set; }
[DisplayName("Do you need tickets for this event?")]
public bool NeedTickets { get; set; }
public string PageName { get; set; }
}
}
i am guessing i need to add for sure, HiddenFor in Partial and maybe public string in Models?
Pass CurrentPage.Name as Hidden value via form
I have a form that i can add using Rich Text Editor via Macro, i want to include CurrentPage.Name as hidden value that is passed on submit
what would be the syntax for it? something like @{ var currentPageName = CurrentPage.Name; }
@HtmlHiddenFor(???, currentPageName??)
here is working code i have currently without passing hiddenvalue
Partial
Model
i am guessing i need to add for sure, HiddenFor in Partial and maybe public string in Models?
how woult that look in the cod?
The following should do the trick:
thanks, another way is to just add this in controller:
is working on a reply...