I wonder if it's possible to create an extension method which has functionality & behaviour similar to Html.BeginForm(), in that it would generate a complete Html tag, and I could specificy its contents inside <% { & } %>
tags.
For example, I could have a view like:
<% using(Html.BeginDiv("divId")) %>
<% { %>
<!-- Form content goes here -->
<% } %>
This capability would be very useful in the context of the functionality I'm trying to produce with the example in this question
This would give me the ability to create containers for the types that I'll be
<% var myType = new MyType(123, 234); %>
<% var tag = new TagBuilder("div"); %>
<% using(Html.BeginDiv<MyType>(myType, tag) %>
<% { %>
<!-- controls used for the configuration of MyType -->
<!-- represented in the context of a HTML element, e.g.: -->
<div class="MyType" prop1="123" prop2="234">
<!-- add a select here -->
<!-- add a radio control here -->
<!-- whatever, it represents elements in the context of their type -->
</div>
<% } %>
I realise this will produce invalid XHTML, but I think there could be other benefits that outweigh this, especially since this project doesn't require that the XHTML validate to the W3C standards.
Thanks
Dave