Perpetuate form content on server side validation error
I have built a form for site visitors to register as a Member. They enter Name, Email (also used as Username and Login) and Password and the code creates the member records. This works fine.
Where I'm stuck is when the email entered already exists. I check for this with
if (Services.MemberService.Exists(vEmail))
which returns me to the page with the form. But the form is empty and I want to populate it with the information already entered.
How do I do this? Here are the relevant bits of the code:
Model
public class MemberRegistrationModel
{
[Required]
public string Name { get; set; }
[Required]
[EmailAddress]`enter code here`
public string Email { get; set; }
Controller
[HttpPost]
public ActionResult HandleFormSubmit(MemberRegistrationModel model)
{
if (!ModelState.IsValid)
return RedirectToCurrentUmbracoPage();
string vDomainName = model.domainName;
string vName = model.Name.Trim();
string vEmail = model.Email.Trim();
string vPassword = model.Password;
//Check if the email address already exists.
if (Services.MemberService.Exists(vEmail))
return RedirectToCurrentUmbracoPage();
Perpetuate form content on server side validation error
I have built a form for site visitors to register as a Member. They enter Name, Email (also used as Username and Login) and Password and the code creates the member records. This works fine.
Where I'm stuck is when the email entered already exists. I check for this with
which returns me to the page with the form. But the form is empty and I want to populate it with the information already entered.
How do I do this? Here are the relevant bits of the code:
Model
Controller
Partial View
Your help would be much appreciated.
Thanking you in anticipation.
Roger
I eventually fixed this by using a session variable
is working on a reply...