Latest Entries

HTML5 Form Helpers For WebMatrix

calendar_today 20 September 2012 14:56

Extension Method ASP.NET Web Pages WebMatrix HTML5

It's an odd thing: WebMatrix 2 is lauded for its support of HTML5, but the Web Pages framework doesn't include any helpers for the new HTML5 form input types such as email or color. It's fair to say that support among browsers for the new inputs is patchy at the moment, but with barely a week flying past without a new version of one or other browser being released, it won't take long for that to change. So in the meantime, if you prefer to use helpers, you have to write your own for rendering HTML5 forms.

Cannot use a lambda expression as an argument to a dynamically dispatched operation

calendar_today 18 September 2012 08:08


Since the introduction of the Web Pages framework, ASP.NET has been making use of the dynamic type introduced in C# 4.0. Along with that comes some new error messages which at first glance don't make a lot of sense - mainly because they are unexpected. I have already looked at how dynamics do not support extension methods, and a recent question in the ASP.NET forums illustrated another way in which the dynamic type can catch you out.

Optimising ASP.NET Web Pages Sites - Bundling And Minification

calendar_today 15 September 2012 17:05

ASP.NET Web Pages WebMatrix

ASP.NET 4.5 saw the introduction of new features for improving the performance of web sites. Delivered within a new library called System.Web.Optimization, bundling and minification enables you to combine multiple JavaScript or CSS files into one bundle, and to minify them thereby reducing the number of HTTP requests that browsers have to make, reducing the size of the files, and improving performance of the site overall, especially over slower (read 3G) networks.

WebMatrix - jQuery Cascading Dropdown Lists

calendar_today 08 September 2012 09:56

jQuery ASP.NET Web Pages WebMatrix

I have looked at cascading dropdown lists with WebMatrix previously, but the approach I featured demonstrated the use of jQuery Templates. At the time, the jQuery Templates project looked promising, but since then, the jQuery team have decided not to take them beyond beta stage. So the reason for this article is to illustrate a more "traditional" jQuery approach to managing cascading dropdown lists when developing ASP.NET Web Pages using WebMatrix.

ASP.NET Web Pages - Creating Custom Validators

calendar_today 31 August 2012 14:33

ASP.NET Web Pages WebMatrix

Version 2 of the Web Pages framework includes a new validation framework. Included are a number of specific validators that cover common scenarios such as validating for presence, data type or range. It may be however, that you want to create your own custom validator to test for something that isn't covered by the existing validators, or to combine multiple tests in one composite validator. Fortunately, the Web Pages team have made the validation system extensible so that you can create your own validators.

Book Review - jQuery Mobile Web Development Essentials

calendar_today 07 August 2012 21:07

jQuery Book Review

The imminent release of Visual Studio (2012) will include jQuery Mobile as part of the ASP.NET MVC 4 Mobile application template, and some enhancements to the framework to make developing for mobile devices much easier. So it was a well-timed invitation that I received from Packt Publishing to review their latest jQuery title: jQuery Mobile Web Development Essentials.

Working With Entity Framework Code First And JSON In ASP.NET Web Pages

calendar_today 22 July 2012 20:46

Entity Framework ASP.NET Web Pages WebMatrix

If you want to build AJAX powered rich client interfaces with ASP.NET Web Pages, you will work with JSON - a lot. You might also be attracted to the Entity Framework for your data access technology. There are some special considerations to take account of when serialising Entity Framework objects to JSON for use in Web Pages applications. This article explores some of the issues you will encounter through the example of a simple To Do list manager.

Transferring Data Between ASP.NET Web Pages

calendar_today 14 July 2012 20:24

ASP.NET Web Pages WebMatrix

There are a huge number of articles and blog posts on persisting data between user requests in ASP.NET. However, the ASP.NET Web Pages framework introduces a couple of additional mechanisms so this article explores those, as well as reviewing some of the standard approaches already available to Web Pages developers from other parts of the ASP.NET framework.

Validation In Razor Web Pages 2

calendar_today 14 June 2012 12:47

jQuery ASP.NET Web Pages WebMatrix Razor

The new release of ASP.NET Web Pages - version 2 - doesn't include many obvious changes, but the most significant one is an enhanced Validation system. A couple of new classes have been introduced, and Web Pages validation now works with the MVC Unobtrusive jQuery validation library. This article explores the new validation system and sees what it brings to the party.

Using Knockout With Razor Web Pages In WebMatrix 2

calendar_today 09 June 2012 11:40

jQuery ASP.NET Web Pages WebMatrix Razor

Knockout is an increasingly popular JavaScript UI library. Its popularity is likely to increase among ASP.NET developers soon as it comes as part of some of the new MVC 4 site templates. This article looks at what Knockout is, what problems it is intended it solve and how to use it in an ASP.NET Razor Web Pages site built in WebMatrix.

Efficiently Displaying Hierarchical Data With The jQuery Accordion In Razor Web Pages

calendar_today 03 June 2012 10:30

jQuery ASP.NET Web Pages WebMatrix Razor

A frequent requirement is to display data hierarchically, such as products by category. This article shows how to use LINQ to Objects and the jQuery Accordion to display the result of a database query in such a fashion within Razor Web Pages.

View Model Design And Use In Razor Views

calendar_today 26 May 2012 23:21


The recommended practice for transferring data to and from views in ASP.NET MVC is to use a View Model. But what is a View Model? How to you design one and how should they be used? This article attempts to provide answers to those questions.

More Flexible Routing For ASP.NET Web Pages

calendar_today 01 February 2012 21:52

ASP.NET Web Pages WebMatrix Razor

The built-in Web Pages routing system offers a fair degree of freedom in terms of how friendly URLs can be constructed and managed. However, the major limitation with the standard routing mechanism is that it relies on matching segments of the URL to files on disk. ASP.NET MVC and Web Forms enjoy a much more flexible routing system. This article looks at a Package that brings full ASP.NET routing control to Web Pages and examines how to use it.

Using The Themes Helper In Razor Web Pages

calendar_today 02 January 2012 18:31

ASP.NET Web Pages WebMatrix Razor

Web site skinning is a concept where by a web application user can personalise their experience, by choosing from a selection of prepared themes or skins. Each theme or skin might offer a different design, or content, or both. ASP.NET Web Forms has included a comprehensive Themes framework since version 2.0. WebMatrix developers can find Themes management functionality in the ASP.NET Web Helpers Library package available through the Package Manager. This article looks at how the Themes helper works.

Building A Razor Web Pages Site With Database First And Entity Framework

calendar_today 30 December 2011 15:25

Entity Framework ASP.NET Web Pages WebMatrix Razor

Since I published an item covering Code First development with Entity Framework and WebMatrix, I have had a few requests to provide a guide to working with the Entity Framework from a database first point of view. This post answers those requests and provides a step by step guide to getting up and running with a WebMatrix web site based on the Northwind sample database that comes with SQL Server CE 4.0.

HTML Helpers For Forms In Razor Web Pages

calendar_today 25 December 2011 11:27

HTML ASP.NET Web Pages WebMatrix Razor

A nugget that has remained partially hidden from view within the Web Pages framework is the HtmlHelper class. Parts of this class peek out in the template sites provided in WebMatrix where validation is performed and related messages displayed, but a vast range of methods designed for rendering form inputs are often overlooked in tutorials, blog articles and books (mine included). This article provides an overview of Web Pages HTML Helpers, and digs into one or two in more detail.

Globalization And Localization With Razor Web Pages

calendar_today 10 October 2011 21:35

ASP.NET Web Pages WebMatrix Razor

Globalization is the process of preparing your site so that it is accessible to as wide an audience as possible. This is largely achieved by presenting content in the native language of the visitor. This article explores how you can approach this task within the ASP.NET Web Pages framework.

Entity Framework Code First Development With WebMatrix

calendar_today 05 September 2011 17:27

Entity Framework ASP.NET Web Pages WebMatrix Razor

The existing data access story for WebMatrix is the Database Helper. Microsoft's recommended data access technology going forward is the Entity Framework (EF). This article explores how to use the Code First capability offered by EF within an ASP.NET Web Pages application.

The WebGrid - Efficient Paging And Sorting With SQL CE 4.0

calendar_today 28 August 2011 22:46

ASP.NET Web Pages WebMatrix Razor WebGrid

A problem inherent in the existing version of the WebGrid is that it is not very efficient when it comes to paging data out of the box. If you have 10,000 rows of data, and you want to display 10 rows per page, all 10,000 rows are retrieved from the database for each page. The grid works out how to only show the current 10, and wastes the other 9,990 rows. That's a fair sized overhead on each page. Ideally, you should only retrieve the data you need for each page. This article examines how you can do that with the existing WebGrid and a SQL CE database, while still maintaining sorting capabilities.

Displaying Search Results In A WebGrid

calendar_today 27 August 2011 16:57

jQuery ASP.NET Web Pages WebMatrix Razor WebGrid

A number of people have run into problems when trying to combine a search or filter form, and a WebGrid. The main issue that arises is when paging or sorting the search result or a filtered subset of it. Here, I look at the cause of the problem and what you can do about it.