Skip to content

Lists generator

Alexanderius edited this page Jun 7, 2024 · 2 revisions

Lists generator

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

Example

    public class MyController : Controller
    {
        public override ControllerResponse Invoke()
        {
            // This call will generate HTML "<option>" items list with months which you then can 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