Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm a novice ASP.NET MVC programmer coming from the .NET Desktop world.

In my desktop applications, I auto-generate a lot of UI: create a data model, add some attributes, and off you go.

class Person
{
    [TextboxEditor(MaxLength=50)]
    public string Name;
    [DateEditor]
    public DateTime Birthdate;
}
[..]
{
    List<Person> list = new List<Person>();
    form.AddControl(new GenericEditor(list));
}

For that, I created my own library.

Is there a less cumbersome way in ASP.NET MVC to accomplish the same thing?

I want to put a List<Person> into it, and it automatically creates a list editor.
Then, I want to be able to configure the behaviour in detail:

  • allow / disallow editing based on permissions
  • input validation
  • Ideally, it should also be possible to insert this list as part of another page. Something like a user control, but in MVC.

I do not want to use code generators, I want the UI to be generated on-the-fly.

Something like:

class PeopleListController: GenericController<List<Person>>
{
    public void Init(List<Person> model)
    {
        base.BindTo(model);
        AllowEditing(...);
        ConfigureSomeMoreStuff(...);
    }
}
share|improve this question

closed as off-topic by gnat, GlenH7, Dan Pichelman, MichaelT, Kilian Foth Nov 19 '14 at 18:07

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions asking us to recommend a tool, library or favorite off-site resource are off-topic for Programmers as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it." – gnat, GlenH7, Dan Pichelman, MichaelT, Kilian Foth
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

That's part of the ASP.NET MVC framework itself. Check out EditorExtensions

Html.EditorForModel();

That should auto generate HTML for each public property of the model. There are other overloads there that let you control what your html ends up looking like more.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.