qt8gt0bxhw|20009F4EEE83|RyanMain|subtext_Content|Text|0xfbffa90000000000ad00000001000300
I came across an interesting article on CodeProject today from a guy named Piers Williams. The article discusses an attribute based strategy for automatic population of instance fields and properties on an ASP.NET page from parameters supplied via properties of the Request object (.QueryString, .Form etc...). A very interesting approach. I am not endorsing using it and haven't really considered the performance impact that this might have - but what I found interesting was the approach. I really like to see people think outside the box. To look at a tedious or repetative task and find a better solution for it.
This approach allows you to populate instance fields & properties using attrubutes which specify the QueryString or Form parameter to bind to.
[WebParameter()]
protected string FirstName;
[WebParameter("Last_Name")]
protected string LastName;
[WebParameter(IsRequired=true)]
protected int CustomerID;
Even add defaults:
[QueryParameter("CustID", DefaultValue="0")]
public int CustomerID;
Very cool. Pretty smooth and a great idea. You can see the entire article here: Declarative QueryString Parameter Binding.