views:

13

answers:

0

So,

We are currently looking at creating a web app in MVC with mind to creating a win forms app at a later date. The two will be almost identical in layout and usage.

With this in mind we are looking at creating our MVC views by dynamically creating the html controls from an xml file. Such as

<Page>
  <ID>Site</ID>
  <Object>
    <ID>PostCodeLabel</ID>
    <Type>label</Type>
    <Attributes>
      <Attribute name="class">display-label</Attribute>
    </Attributes>
    <Value>PostCode</Value>
  </Object>
  <Object>
    <ID>PostCode</ID>
    <Type>input</Type>
    <Attributes>
      <Attribute name="class">display-field</Attribute>
      <Attribute name="type">text</Attribute>
    </Attributes>
    <Value>$PostCode</Value>
  </Object>
</Page>

The intention being that we can then use this script to generate the controls on the webform as well. Keeping them the same.

I've looked at a couple of different methods for this such as writing a view engine that uses xslt to transform the page (retrieving some info from the database as well).

I might be able to incorporate this

http://www.nerdmotivation101.com/post/2008/11/17/ASPNET-MVC-Building-Dynamic-Forms-with-the-Builder-Pattern.aspx

But does anyone else have any other suggestions or advice? Is this a good idea?

Thanks in advance