Date picker widget: Define the date picker control

To define the date picker control, perform the following:

  1. In the context menu of the project, click Add » New Item...
  2. In the left pane, select Visual C# Items » Code.
  3. Click Class and in the Name input field, enter DatePickerField.
  4. Change the class definition to inherit from FieldControl and IFormFieldControl classes.
  5. Add a constructor that adds a default value to the title to Untitled.
  6. Add a JavaScript serializer to the class.
  7. Provide properties for common date picker fields.
  8. Provide a property for accessing the value in the date picker that is currently selected.:
  9. Save the file.

GITHUB EXAMPLE: For more information about the content of the file, see the DatePickerField.cs file of the downloaded sample project.

You create properties for the minimum and the maximum dates that user can select, the value that is currently selected and the meta information. When defining the Value property you refer the DatePicker field from the template. For more information, see Date picker widget: Reference the template in the control.

Next, you must define the visuals of the date picker control.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?