IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
This article explains how to build a custom widget based on the built-in Form widget. The custom widget displays the titles of all the forms from the Forms module in a dropdown box. When the user selects a form in the dropdown box, the widget displays the respective form. When the user fills out the form, the system saves a form response in the Forms module.
The following procedure mentions only the more important steps from the implementation of the custom form widget.
The custom widget inherits from FormsControl. This is because the widget is working with the ID of the form after it is selected and can be used on the frontend to display the selected form.
Perform the following:
public class FormsControlCustom : FormsControl
public override string LayoutTemplatePath
{
get
return this.layoutTemplatePath;
}
set
base.LayoutTemplatePath = value;
var selectedValue = HttpContext.Current.Request.QueryString["formId"];
<
script
language
=
"javascript"
type
"text/javascript"
>
function OnClientSelectedIndexChanged(sender, eventArgs) {
var item = eventArgs.get_item();
//sender.set_text("You selected " + item.get_text());
var currentHref = window.location.href.split("?")[0];
if (currentHref) {
var redirectString = currentHref + "?formId=" + item.get_value()
window.location.replace(redirectString);
return false;
</
To get the correct results, method OnClientSelectedIndexChanged makes a redirection to the selected form.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important