RSS 2.0 Feed
RSS 2.0


Atom 1.0 Feed
Atom 1.0

  ASP.NET QueryString Parameter Binding 


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.




                   



Leave a comment below.

Comments

  1. Fabrice 5/17/2005 4:21 PM
    Gravatar
    There is a new product along the same lines that helps to work with URLs: PageMethods.
    PageMethods enables well-defined URLs using methods and attributes.
    Learn more at http://metaSapiens.com/PageMethods
  2. 9/19/2009 3:30 AM
    Gravatar
    olusqxlu - Google Search
  3. 11/22/2009 6:26 AM
    Gravatar
    nugvjrix - Google Search
Comments have been closed on this topic.



 

News


Also see my CRM Developer blog

Connect:   @ryanfarley@mastodon.social

         

Sponsor

Sections