Fubumvc - rendering a collection as a drop-down list

I am having trouble understanding how to make a collection a drop down list.

If I have a model, for example:

public class AccountViewModel {             

    public string[] Country { get; set; }
}

I would like the row assembly to display as a dropdown.

Using the html page helper InputFor does not work. It just displays a text box.

I noticed that InputFor can reflect the type of property and render html accordingly. (As a check box for a logical field).

I also notice that FubuPageExtensions has methods for CheckBoxFor and TextBoxFor, but nothing is equivalent to DropDownListFor.

I probably have something completely fundamental in understanding html conventions in fubu.

Do I need to create a select tag myself? If so, what is the recommended approach for this?

+5
1

, ( , ) FubuMVC.Core HTML , HtmlTags library select .

, , , , HTML HtmlTags, FubuMVC.Recipes example 'src/UI/HtmlConventionsWithPageExtensions'.

, :

this.Editors
    .If(e => e.Accessor.PropertyType.IsEnum)
    .BuildBy(er =>
    {
        var tag = new HtmlTag("select");
        var enumValues = Enum.GetValues(er.Accessor.PropertyType);
        foreach (var enumValue in enumValues)
        {
            tag.Children.Add(new HtmlTag("option").Text(enumValue.ToString()));
        }

        return tag;
    });

FubuMVC.Recipes , , , .

+10
source

All Articles