We get up early so that you don't have to. |
PageMethods for Visual Studio 2003, Free
metaSapiens
http://metasapiens.com/PageMethods/Default.aspx
If you've written any ASP.NET applications, odds are pretty good that you've had pages with parameters, and pages that passed data to other pages. Maybe you just shoved everything into session state and then took it out again in the Page Load event, and trusted that the site would be lightly enough used that the memory requirements would stay reasonable. Or maybe you ended up with URLs that looked like http://www.example.org/item.aspx?ID=57&Action=Display and started off every page with a bunch of string processing to split up the QueryString and then convert all the parameters back to their proper data types. Sure, the code is routine, but it's boring and time-consuming, and you don't get any compile-time error-checking of what you're doing.
PageMethods is designed to simplify your life by letting you add methods to your ASP.NET pages that represent the ways of calling the page. For example, the item.aspx page might contain this code:
[PageMethod]
protected void DisplayItem([ParamName("ItemID")] int ID)
{
// code to display appropriate item goes here
}
And to set up the link on the calling page you'd have code like this:
lnkDisplayItem.NavigateUrl =
MyPageMethods.Items.FrmItemActions.DisplayItem(itemID);
DataBind();
You even get the benefits of IntelliSense and compile-time checking when you're writing the calling code.
The plumbing is remarkably easy to set up. Add a reference to the PageMethods library, and decorate your methods and parameters with the appropriate attributes. You need to call the PageMethods engine in your Page Load event to set everything up, and activate the framework in the project properties. PageMethods itself will generate a batch of code and stick it off in a subfolder, but you don't even have to look at this. You can just use it, and it just works, so far as I can tell. You'll also find other goodies here, including support for extracting parameters from URLs generated with URL rewriting, support for formatted parameters, and support for required parameters. There's a VS2005 version in the works, and the price is certainly right as well.
Mike Gunderloy is the lead developer for Larkware and author of numerous books and articles on programming topics.