Creating strongly typed rendering parameters

In the previous recipe, you learned using additional parameters, but these are loosely typed. So, chances are that content authors may enter invalid values such as non-numeric values for the RecordsCount parameter and a style class in CssClass that does not exist, and so on, which can lead to misbehavior of the application. Now, just imagine how happier your content authors will be if they see strongly typed parameters such as checkbox, integer, droplist, and so on.

In this recipe, we will use the Integer field for RecordsCount and a Droplist field for CssClass so that we always get valid values from the input.

Getting ready

Create a Stylesheet Class template and create different items outside the Home ...

Get Sitecore Cookbook for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.