How to reset Form

2025/03/06 8:52 AM

Hello Community,

I have created one form which has email field and submit button. This form is rendered inside one popup which is shown to users when they want to download whitepaper. once they fill the details i sent an email and one message is displayed

now there are multiple whitepaper for which this popup is shown. When user fills the form message is displayed and email is received by them but when user clicks on another white paper instead of email fields and submit button, the message is displayed. I have to refresh the page to see form again. So my conclusion is that form is not reset.

I want to rest the form when popup is clicked again. Also i want to mention that i am using CustomFormSubmitAutomationEmailProvider as kentico documentation suggested to sent the email.

So, How do i do that ??

Environment

  • Xperience by Kentico version: [30.1.0]
  • .NET version: [8]

Answers

2025/03/07 2:46 PM

Can you load the content of the popup asynchronously? Have you tried something like this?

2025/03/13 7:34 AM

Yes, I have created Partial View of popup and loaded content using PartialAsync on my page. i want to reset the form when user closes the popup or when user opens the popup. either one will work.

2025/03/13 8:32 PM

I assume you're using a single form for all whitepapers. Controlling the UX with the built-in Form widget can be limiting. If you need more flexibility, I would consider this approach:

  1. Create a custom controller to handle POST requests. This controller should receive the form codename and submitted data, validate them, and store them as XbyK Form data. You can refer to the API examples for form operations.
  2. Generate the form dynamically using JavaScript instead of relying on the Form widget, especially since the popup is likely controlled by JavaScript as well. On form submission, send the data to your custom controller via a client-side request.
  3. Handle post-submission behavior by displaying a confirmation message. Then, reset the form using JavaScript when the popup is closed and reopened.

To answer this question, you have to login first.