AJAX forms events

PREREQUISITES: You have enabled the AJAX submit call functionality for the Forms module. For more information, see Submit forms using AJAX call.

IFormValidatingEvent

The following interface is implemented by all events raised before a form is validated. There is only one such built-in event FormValidatingEvent and you must subscribe to the interface rather than the class that implements it. Subscribe to the event using the following code:

The above example demonstrates how to check for invalid input.
As a result, if you attempt to submit the form with a value that does not match the validation criteria, an error message The 'Name' field must consist of two words. is displayed.

In the event handler, you can access the following information:

  • The ID of the user submitting the form.
  • The user name of the user submitting the form.
  • The IP address of the client that submits the form entry.
  • The ID of the form being submitted.
  • The unique (code) name of the form being submitted.
  • The title of the form being submitted.
  • The origin of the event.
  • A collection of the form controls that you can use to retrieve the forms' title, values, and so forth.

IFormFieldValidatingEvent

This interface is implemented by the FormFieldValidatingEvent and is raised when a form field is validated. Subscribe to the event using the following code:

In the event handler, you can access the following information:

  • The origin of the event.
  • The field that is being validated.

IFormEvent

This interface is a contract for events that contain all form data. The interface inherits the IFormModuleEvent. The IFormEvent is implemented by the following events:

  • BeforeFormActionEvent - the event is raised before the form action gets executed, for example redirecting to another page or showing a success message.
  • FormSavingEvent - the event is raised before a form is saved.
  • FormSavedEvent - the event is raised after a form is saved.

NOTE: If an action is cancelled, the event handlers throw Telerik.Sitefinity.Services.Events.CancelationException.

Anytime an action related to forms is executed, the IFormEvent is raised. To subscribe to the event, use the following code:

>

Want to learn more?

Sign up for our free beginner training. Boost your credentials through advanced courses and certification.
Register for Sitefinity training and certification.

Was this article helpful?