How to compare two e-mail addresses on bizform

   —   
This article shows how to compare two e-mail addresses on bizform to make sure, that the e-mail address is correct.
1. Please add two field of e-mail type to your bizform in CMSDesk -> Tools -> BizForms -> edit -> Fields. Note their code names.

2. Add OnBeforeSave event handler to your bizform´s code-behind (protected void viewBiz_OnBeforeSave()).

3. You can use this code, where “Email” and “ValidateEmail” are code-names of your e-mail fields.

protected void viewBiz_OnBeforeSave()
{

CMS.FormControls.FormEngineUserControl em1 = (CMS.FormControls.FormEngineUserControl)viewBiz.BasicForm.FieldControls
["Email"];

CMS.FormControls.FormEngineUserControl em2 = (CMS.FormControls.FormEngineUserControl)viewBiz.BasicForm.FieldControls
["ValidateEmail"];


string EmailAddress = em1.Value.ToString();
string ValidateEmailAddress = em2.Value.ToString();


if (EmailAddress != ValidateEmailAddress)
{

Response.Write("E-mail addresses must match!");
this.viewBiz.StopProcessing = true;

}

}




See also: devnet.kentico.com/docs/devguide/modifying_the_code_of_standard_web_parts.htm

Applies to: Kentico CMS 4.x
Share this article on   LinkedIn

Juraj Ondrus

Hi, I am the Technical support leader at Kentico. I'm here to help you use Kentico and get as much as possible out of it.