Try our conversational search powered by Generative AI!

How to cancel a Form submission.

Vote:
 

How can forms submissions be canceled? Below is the current code base that I am working from. I hooked into the form submission event for custom processing, but I need a way to cancel the form submission, if the custom validation fails. 

 private void FormsEvents_formSubmission(object sender, FormsEventArgs e)
{
	if (!string.IsNullOrEmpty(e.FormsContent.Name))
	{
		var contentRouteHelper = ServiceLocator.Current.GetInstance();
		var submitArgs = e as FormsSubmittingEventArgs;
		
		// validation 
		
		//Process form
		if(valid){
			//todo 
		}else{
			// cancel subimssion. 
		}
	}

}
#149424
May 31, 2016 18:32
Vote:
 
submitArgs.CancelAction = true;
submitArgs.CancelReason = "reason";
#149429
May 31, 2016 20:33
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.