protected void Page_Init(object sender, EventArgs e)
{
BizForm.FormName = KenticoHelper.GetDocumentValueByKey("BizFormName");
BizForm.OnBeforeSave += BizForm_OnBeforeSave;
}
protected void BizForm_OnBeforeSave()
{
CMS.FormControls.FormEngineUserControl em1 = (CMS.FormControls.FormEngineUserControl)BizForm.BasicForm.FieldControls["EmailAddress"];
CMS.FormControls.FormEngineUserControl em2 = (CMS.FormControls.FormEngineUserControl)BizForm.BasicForm.FieldControls["ConfirmEmailAddress"];
string EmailAddress = em1.Value.ToString();
string ValidateEmailAddress = em2.Value.ToString();
if (EmailAddress != ValidateEmailAddress)
{
CMS.ExtendedControls.LocalizedLabel ictrl = (CMS.ExtendedControls.LocalizedLabel)BizForm.BasicForm.FieldErrorLabels["ConfirmEmailAddress"];
ictrl.Visible = true;
ictrl.Text = "The e-mail addresses do not match, please check it.";
this.BizForm.StopProcessing = true;
}
CheckBox cbAgreeTerms = (CheckBox)BizForm.BasicForm.FieldControls["AgreeTerms"];
if (!cbAgreeTerms.Checked)
{
CMS.ExtendedControls.LocalizedLabel agreeTerms_ErrorLabel = (CMS.ExtendedControls.LocalizedLabel)BizForm.BasicForm.FieldErrorLabels["AgreeTerms"];
agreeTerms_ErrorLabel.Visible = true;
agreeTerms_ErrorLabel.Text = "Field Required.";
this.BizForm.StopProcessing = true;
}
CheckBox cbUnderstandConfidential = (CheckBox)BizForm.BasicForm.FieldControls["UnderstandConfidential"];
if (!cbUnderstandConfidential.Checked)
{
CMS.ExtendedControls.LocalizedLabel understandConfidential_ErrorLabel = (CMS.ExtendedControls.LocalizedLabel)BizForm.BasicForm.FieldErrorLabels["UnderstandConfidential"];
understandConfidential_ErrorLabel.Visible = true;
understandConfidential_ErrorLabel.Text = "Field Required.";
this.BizForm.StopProcessing = true;
}
CheckBox cbUnderstandChecks = (CheckBox)BizForm.BasicForm.FieldControls["UnderstandChecks"];
if (!cbUnderstandChecks.Checked)
{
CMS.ExtendedControls.LocalizedLabel understandChecks_ErrorLabel = (CMS.ExtendedControls.LocalizedLabel)BizForm.BasicForm.FieldErrorLabels["UnderstandChecks"];
understandChecks_ErrorLabel.Visible = true;
understandChecks_ErrorLabel.Text = "Field Required.";
this.BizForm.StopProcessing = true;
}
}