Skip to content

Lists generator

Alexanderius edited this page Jul 3, 2025 · 3 revisions

Lists generator

ListsGenerator is a class for HTML select control generation. It can generate lists of numbers, years, months, etc.

Example

public class MyController : Controller
{
    public override ControllerResponse Invoke()
    {
        // This call will generate an HTML "<option>" items list with months, which you can then set in your combo boxes
        var monthsList = Html.ListsGenerator.GenerateMonthsList();
        someTpl.Set("Items", monthsList);
        ...
    }
}

Some template

<select name="Months">
{Items}
</select>

End result

<select name="Months">
    <option value='' selected='selected'>Default label</option>
    <option value='0' >January</option>
    <option value='1' >February</option>
    <option value='2' >March</option>
    <option value='3' >April</option>
    <option value='4' >May</option>
    <option value='5' >June</option>
    <option value='6' >July</option>
    <option value='7' >August</option>
    <option value='8' >September</option>
    <option value='9' >October</option>
    <option value='10' >November</option>
    <option value='11' >December</option>
</select>

<< Previous page Next page >>

Clone this wiki locally