Search code examples
asp.netruby-on-railsclassediting

Can you create an ASP.NET editing system for a class just by defining it?


I was watching a tutorial on Rails and was very impressed that you could so easily create an editing system for a class just by defining it.

Can this be done in ASP.NET?

I know there are ORMs out there, but do they come with an editing system?

To explain what I mean by an editing system, consider a class for defining people

class Person
{
  string First_Name;
  string Last_Name
}

And then perhaps with one bold stroke something like this:

CreateEditAbleClass(Person)

You would get the functionality below in a browser:

http://www.yart.com.au/images/orm_editor.jpg

And this functionality would extend to all the UML definitions – inheritance, association, aggregation etc. In addition, there would be a simple way of adding customisable validation and so forth.

I currently use DataGrids and a lot of manual coding to achieve these results.


Solution

  • You can do it with reflection. Using reflection, you can enumerate over the members of a class, and therefore create a form to edit the members.

    Creating the code for rendering the web form based on the members of the class is a bit more code then I'm willing to type out here, but if you look into reflection you should be able to come up with your own solution in a couple hours.