Back in January 2006 I wrote a blog post about a way to add input validation to declarative query string parameters in ASP.NET 2.0.
This involved adding code to the code-behind of each ASP.NET page to hook an event handler. This quickly becomes tedious if you have a lot of pages.
Will Shaver has come up with a better approach. He derives a custom class ValidatedQueryStringParameter from the ASP.NET class QueryStringParameter.
Check out the download on his blog post. It contains a more complete ValidatedQueryStringParameter class that supports other types besides Int32 like DateTime and Boolean. The QueryStringParameter already supports a Type property (of type TypeCode) to specify the type for the value of the parameter, so you can use it from markup like so:
<cc:ValidatedQueryStringParameter Name="CategoryId" QueryStringField="CategoryId" DefaultValue="0" Type="Int32" />