ASPX templates
Version 3.x > ASPX templates > how to stop processing of BizForm View modes: 
User avatar
Member
Member
kbonett@uniteform.com - 7/10/2008 6:52:17 AM
   
how to stop processing of BizForm
I have copied the BizForm webpart so I can modify some code - I need to be able to compare email addresses and alert if they do not match.

The form also uses in-built validation which stops priocessing if emails are not in correct format (regexp), and if required fields are left empty.

My code alerts if emails do not match. Good so far. However, if all required fields are completed AND (non-matching) emails are in correct format, the form gets submitted.

How do I prevent this so that user can correct the email?

I have used "BizFormNew.BasicForm.StopProcessing;" in the code below, but I get a compiler error.


Here's my code in ASCX file:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="~/CMSTemplates/SBAC/WebParts/bizformsbaccompetition.ascx.cs" Inherits="CMSTemplates_SBAC_WebParts_bizformsbaccompetition" %>

<cms:BizForm ID="BizFormNew" runat="server" OnOnBeforeValidate="Compare" />
<asp:Label CssClass="EmailCompare" ID="lblCompare" runat="server" Text=""></asp:Label>

Here's my code in ASCX.CS file:

/// <summary>
/// Content loaded event handler
/// </summary>
public override void OnContentLoaded()
{
base.OnContentLoaded();
SetupControl();
lblCompare.Text = ""; //reset error msg for comparing emails - used below in Compare()
}

/// <summary>
/// Compare 2 email addresses
/// </summary>
protected void Compare()
{
Control email1 = BizFormNew.BasicForm.FindControl("Email");
Control email2 = BizFormNew.BasicForm.FindControl("ConfirmEmail");

if (((TextBox)email1).Text != ((TextBox)email2).Text)
{
lblCompare.Text = "Emails do not match. Please re-enter.";
BizFormNew.BasicForm.StopProcessing;
}
}


Any help much appreciated!

P.S.
I'm not a .NET developer (I know some basic stuff) but have the task of setting up a site using Kentico.




User avatar
Member
Member
kentico_vitaja - 7/14/2008 5:48:27 AM
   
RE:how to stop processing of BizForm
Hi,

You should register your handler in Page_Load() in a similar way to this one:

...
formCustomFields.OnAfterValidate += new DataForm.OnAfterValidateEventHandler(formCustomFields_OnAfterValidate);
...

Then in your OnAfterValidate method you will use your code from Compare() method with a little change:

...
BizFormNew.BasicForm.StopProcessing = true;
...

Best regards,
Vita Janecek

User avatar
Member
Member
kbonett@uniteform.com - 7/14/2008 10:31:05 AM
   
RE:how to stop processing of BizForm
Vita,

I don't understand what I should use instead of "formCustomFields" in the handler?

User avatar
Member
Member
kbonett@uniteform.com - 7/14/2008 10:56:51 AM
   
RE:how to stop processing of BizForm
Vita,

I have now got the logic working correctly by modifying the code in my original post as per your suggestion:

BizFormNew.BasicForm.StopProcessing = true;

BUT... I haven't added a Page_Load handler. Doesn't seem to need it.