ASP.NET MVC 1.0 Release Candidate Now Available
page 11 of 20
by Scott Guthrie
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 67635/ 243

Strongly Typed HTML/AJAX Helpers

One of the requests a few people have asked for is the ability to use strongly-typed expression syntax (instead of strings) when referring to the Model when using a View's HTML and AJAX helper objects.

With the beta build of ASP.NET MVC this wasn't possible, since the HtmlHelper and AjaxHelper helper classes didn't expose the model type in their signature, and so people had to build helper methods directly off of the ViewPage<TModel> base class in order to achieve this. 

The ASP.NET MVC RC build introduces new HtmlHelper<TModel> and AjaxHelper<TModel> types that are exposed on the ViewPage<TModel> base class.  These types now allow anyone to build strongly-typed HTML and AJAX helper extensions that use expression syntax to refer to the View's model.  For example:

Figure 27

The HTML form helper extension methods in the core ASP.NET MVC V1 assembly still use the non-expression based string syntax.  The “MVC Futures” assembly released today (which works with the RC) has a few initial implementations of expression-syntax based form helper methods.   We are going to iterate on these a bit longer and then consider adding them into the ASP.NET MVC core assembly in the next release. 

You can of course also add your own helper methods (using either strings or strongly-typed expressions).  The built-in HTML/AJAX helper methods can also optionally be removed (because they are extension methods) if you want to replace or override them with your own


View Entire Article

User Comments

Title: Awesome article, great work!   
Name: George Loew
Date: 2009-03-25 12:20:05 AM
Comment:
excellent article, scott! It is very useful and contain excellent information about ASP.NET MVC framework. I have had a chance to try this ASP.NET MVC technology with my current host (asphostcentral.com) and everything works beautifully.

I am rating 5 stars for this article and I am looking forward to your next articles.
Title: Cache Photo   
Name: Meysam
Date: 2009-03-05 2:14:50 AM
Comment:
Hi,
Is it possible to send cache status (304) in response to subsequent requests for a photo?

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-10-16 1:32:50 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search