Add parser support for strongly-typed controls
I think the model binding proposed in the Visual Studio 11 Preview is a great feature, but I think it could be made MUCH more powerful. I would like to see strongly-typed controls be something more like:
<asp:SomeControl ID="SomeControl1" runat="server" RuntimeType="string" />
Where SomeControl would be defined as:
public class SomeControl<T> : Control { }
And in the generated code, the markup would translate to:
protected SomeControl<string> SomeControl1;
The basic gist is to add in a special property like runat="Server" that would allow you to specify the T in Control<T> or T1 and T2 in Control<T1, T2>.
2 comments
-
Jeffrey Morse
commented
In addition to what has been suggested (which I woudl like to see better syntax):
<ns:SomeControl{string} ID="SomeControl1" runat="server" />
I would extend this by suggesting that markup fully support generics, such that a control could both instantiate a generic type by filling out the generic type parameters and use generic type parameters it defines itself (such as for a generic UserControl which could have a generic child as follows):
public partial class MyUserControl<T> : UserControl
{
}Markup for MyUserControl<T>:
<div>
<ns:SomeControl{T} ID="SomeControl1" runat="server" />
</div> -
Mark Hildreth
commented
OK, so I found an example of this:
This approachs sounds great and shakes out just the way I hoped it would. The only issue is tooling support.