Jeff Perrin :: Archives for September, 2004

Binding Custom Objects to Forms

Saturday, September 25th, 2004

Yesterday I read an msdn article that describes a method of using reflection to bind objects to a web form. It’s mirrors a technique I’ve been using for almost a year now:

  • Create a UserControl base class with a ‘BoundEntity’ property, which is the entity or object that is to be bound to the control.
  • Specify two methods; BindEntityToControl, and BindControlToEntity. The first takes the BoundEntity and populates corresponding server control properties based on the public Properties of the BoundEntity. The second does the reverse… Populating the BoundEntity properties from their corresponding server controls.
  • Use reflection to find controls that correspond to BoundEntity properties, and then set them accordingly. Controls are mapped to properties by a simple naming convention; control ID’s must have the same value as a BoundEntity property name to be bound.

The main difference in the implementation is that I do the binding with UserControls, while the article uses web forms. I think it makes more sense with my UserControl approach, because it lends itself more to an MVC approach. You can then use the codebehind files as simple Page Controllers, with the UserControl as the view, and the BoundEntity as the model.

Here’s an example of the EntityControl base class I’ve been using:

EntityControl.cs

It would seem…

Wednesday, September 22nd, 2004

… That someone (or something) has taken a crap on Mike’s site. Just in case he changes it to something mo’ betta, here’s a nice little shot of the design I christen; “Steaming Pile”

Just thought I’d point that out.

Getting Busy

Thursday, September 16th, 2004

Things have been heating up nicely at work lately. A few sites have either been launched, or will be shortly. I’m really looking forward to the weekend.

Latest Happenings

Sunday, September 5th, 2004

I’ve just started working on a new CMS web-app called… Yup, you guessed it… TestostelesCms! (I really have to work on coming up with some more original names). The basic design goals are as follows:

  • Author, Edit, Publish workflow on all pages. This is something that open source .NET CMS apps (like DotNetNuke) seem to be missing.
  • Full revision tracking capabilities. You’ll be able to see all the past changes to a page, including who authored the change, and who approved it.
  • Role based access to content publishing channels
  • Open ended site design. I’ll provide a set of useful custom controls that can be dropped on a page, including a bread crumb control, channel content listing controls, page content controls, etc. But other than that, the UI is up to the end-programmer. This will allow you to have a basic CMS, with separate pages for any wacky custom stuff you can devise.

I’ve worked with a few different CMS’ in my time, including Microsoft CMS 2001 and 2002, DotNetNuke, Rainbow, OpenCms (Java), PhpNuke, etc. TestostelesCms will be an amalgamation of some of the concepts I’ve gleaned from these apps.