GenericInput Helper

The Generic input helper is able to render any type of input. It just puts the value provided intto the Html "value" attribute, and add the adequate prefixes to the name provided. This means that also in case of checkboxes The GenericInput uses the value and not the checked property. Moreover, the Rough value of the model state is not copied in the value also in case of validation errors.

You can control everything else with the help of Html attributes and with the help of the MVC Controls Toolkit core functions for manipulating styles and attributes(static methoeds of the MVCControlsToolkit.Core.BasicHtmlHelper class).

This helper might be useful in case one needs TOTAL control over the input field but still want the Mvc engines handles the prefixes automatically.

Below some examples:

 

@Html.GenericInputFor(InputType.Text, m => m.Item, null)


@Html.GenericInputFor(InputType.Hidden, m => m.Deleted, null)

Last edited Jun 22, 2014 at 10:58 AM by frankabbruzzese, version 6

Comments

No comments yet.