As well as doing a Silverlight session at the London .NET User Group on Thursday night, Scott has also offered to do an ASP.NET MVC session this Friday afternoon (3rd July) for Vista Squad at the Microsoft offices just outside Reading from 1pm.
For Friday’s ASP.NET MVC session we originally had a 120 person limit which filled within a few hours but we’ve managed to double the room size! If you want to catch Scott in action, you can register at http://scott-mvc.eventbrite.com/
On the day, registration is at 1pm. The event will finish around 4pm.
I want to thank Zi “I need a longer name for a hyperlink” Makki and the London .NET User Group as well as Ray “Ditto” Booysen and Vista Squad for being able to pull things together so quickly. If you’re in the London area, get along to one (or both) of these groups. And of course thanks to Scott for agreeing to deliver this stuff while he’s just passing through the country.
Picking up where I left off some time back on ASP.NET 4.0, today we take a look at some of the enhancements we’re making to data controls in ASP.NET 4.0. Let’s start with the easy stuff.
Cleaner HTML
Over the years we’ve made significant advances in making the markup generated by ASP.NET server controls standards compliant, flexible and easy to style the way you want with CSS. Whether it be enhancements to the controls themselves, the introduction of new controls such as the ListView control or the creation of the CSS Friendly Control Adapters, all have contributed to greater flexibility and standards compliance in the generated markup.
One control that still suffers from enforcing a table-based layout is the FormView. The markup:
<asp:FormView ID="FormView1" runat="server">
<ItemTemplate>
<div>
<%# Eval("MyData") %>
</div>
</ItemTemplate>
</asp:FormView>
Results in the following HTML:
<TABLE style='BORDER-COLLAPSE: collapse' id=TABLE1 border=0 cellSpacing=0>
<TBODY>
<TR>
<TD colSpan=2>
<DIV>Some Data </DIV>
</TD>
</TR>
</TBODY>
</TABLE>
ie my ItemTemplate is wrapped in a <table> element and there’s nothing I can do about it. The FormView in ASP.NET 4.0 has a new property called RenderTable:
<asp:FormView ID="FormView1" RenderTable="false" runat="server">
<ItemTemplate>
<div>
<%# Eval("MyData") %>
</div>
</ItemTemplate>
</asp:FormView>
Which results in the following when the page renders:
<div>
Some Data
</div>
Simpifying Your Markup
The ListView control was introduced in ASP.NET 3.5 as a powerful, flexible alternative to the GridView control. It gives you complete control over the generated markup. It does have an obsession with LayoutTemplates and ItemPlaceholders though.
The following markup works fine in ASP.NET 4.0 but results in the YSOD in ASP.NET 3.5, complaining that “An item placeholder must be specified on ListView 'ListView1'. Specify an item placeholder by setting a control's ID property to "itemPlaceholder". The item placeholder control must also specify runat="server".”
<asp:ListView ID="ListView1" runat="server">
<ItemTemplate>
<div>
<%# Eval("MyData") %></div>
</ItemTemplate>
</asp:ListView>
It just makes your life that little bit easier.
Persisted Selection
Persisted selection provides a more intuitive user selection experience on both the GridView and ListView controls. In ASP.NET 3.5, if the user selects an item presented in a GridView or ListView and then pages the control, a corresponding item will be selected on the new page. This is because the row selection is simply based on the row index on the page. Thus this ListView control:
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="HomeID">
<ItemTemplate>
<div>
<asp:LinkButton CommandName="Select" runat="server">Select</asp:LinkButton>
<%# Eval("ImageURL") %>
</div>
</ItemTemplate>
<SelectedItemTemplate>
<div>
<em><%# Eval("ImageURL") %></em>
</div>
</SelectedItemTemplate>
</asp:ListView>
Results in the following paging experience for the user:
Setting EnablePersistedSelection="true" on the ListView (or GridView) changes that to the more intuitive experience below:
QueryExtenders
The QueryExtender control works in conjunction with either the LinqDataSource or EntityDataSource controls to modify the query expression generated by the DataSource control to apply additional filter operations (where clause) such as search, range and property matching. You can also include ordering and build your own custom expressions. Let’s take a look at an example starting with this simple LinqDataSource control which queries against my database of fictitious properties
<asp:LinqDataSource ID="LinqDataSource1" runat="server" ContextTypeName="DataClassesDataContext"
EntityTypeName=""
Select="new (HomeID, Bedrooms, ImageURL, Price, Available, Description)"
TableName="Homes">
</asp:LinqDataSource>
Using SQL Server Profiler, I can see that this results in the following query against my DB
SELECT
[t0].[HomeID],
[t0].[Bedrooms],
[t0].[ImageURL],
[t0].[Price],
[t0].[Available]
FROM [dbo].[Homes] AS [t0]
By adding a QueryExtender I can modify the query expression and therefore the query that ultimately runs against my DB
<asp:QueryExtender ID="QueryExtender1" TargetControlID="LinqDataSource1" runat="server">
<asp:OrderByExpression DataField="Price" Direction="Descending"></asp:OrderByExpression>
</asp:QueryExtender>
This results in
SELECT
[t0].[HomeID],
[t0].[Bedrooms],
[t0].[ImageURL],
[t0].[Price],
[t0].[Available],
[t0].[Description]
FROM [dbo].[Homes] AS [t0]
ORDER BY [t0].[Price] DESC
Of course I can take things a lot further by adding additional expressions to my QueryExtender thus
<asp:QueryExtender ID="QueryExtender1" TargetControlID="LinqDataSource1" runat="server">
<asp:OrderByExpression DataField="Price" Direction="Descending"></asp:OrderByExpression>
<asp:RangeExpression DataField="Price" MinType="Inclusive" MaxType="Inclusive">
<asp:Parameter DefaultValue="200000" DbType="Int32" />
<asp:Parameter DefaultValue="750000" DbType="Int32" />
</asp:RangeExpression>
<asp:PropertyExpression>
<asp:Parameter Name="Available" DefaultValue="True" DbType="Boolean" />
</asp:PropertyExpression>
<asp:SearchExpression DataFields="Description" SearchType="Contains">
<asp:Parameter DefaultValue="private" DbType="String" />
</asp:SearchExpression>
</asp:QueryExtender>
Which results in the following T-SQL executing against my DB
exec sp_executesql
N'SELECT [t0].[HomeID],
[t0].[Bedrooms],
[t0].[ImageURL],
[t0].[Price],
[t0].[Available],
[t0].[Description]
FROM
[dbo].[Homes] AS [t0]
WHERE
([t0].[Description] LIKE @p0) AND
([t0].[Available] = @p1) AND
([t0].[Price] >= @p2) AND ([t0].[Price] <= @p3)
ORDER BY
[t0].[Price] DESC',
N'@p0 nvarchar(4000),@p1 int,@p2 int,@p3 int',
@p0=N'%private%',
@p1=1,
@p2=200000,
@p3=750000
So the QueryExtender gives me a simple, but powerful declarative mechanism for customising my queries with either the EntityDataSource or LinqDataSource controls by taking advantage of the the deferred execution and extensible nature of LINQ expressions.
Technorati Tags:
asp.net,
data,
linq
Following on from my post about the Expression family, I said I’d follow up with some more details on Expression Design. Someone commented on my other post that Expression Design is “too basic” and I suppose for many people that will be a fair criticism. For someone like me, who’s not a graphic designer, I find it strikes a good balance between functionality and complexity (and I use some other tools to achieve things Design is not so suited to such as manipulating bitmap images – Paint.NET is great for this). It also comes in a range of attractive colours. Anyway, I’ve done a bit of a trawl to find learning resources for Expression Design.
Finding out about what it does and the basics of the UI
- Follow the “Video Feature Tour” link at the Expression Design Homepage (Silverlight required)
- There’s a more detailed demo video on the same page (“In-Depth Demo”) which covers a tour of the UI, XAML Exporting and Slicing

Getting Started Tutorials etc
More In-Depth Webcast
Download the Trial
Community Help and Assistance
I love the idea of using iconic British images for the Bing homepage. I thought the current one was particularly evocative.
That said, I currently have this beautiful image as my Win7 desktop background (in focus and without the text :-)). It was the winner of last month’s Microsoft UK photography competition and it’s absolutely stunning IMHO. It was taken by David Weeks.

In fact things Bing have moved on and today we have this image on the homepage for the UK.
Which brings me to my one ask for Bing (UK). I have no idea where this place is but I’d love to know. How about some information on the image itself? Where it was taken, when, by whom etc etc. That would be really interesting.
Blend, Encoder, Web, Design, Media, Studio – it’s easy to get confused by the plethora of Expression family products but given we’re nearing another release I thought it might be worth a few posts to try and to try and simplify things as well as provide a “jump-start” for some of the individual tools.
Starting from the beginning, Expression is our brand for more “design” oriented products (as distinct from Visual Studio as our brand for development related products). Now that’s a gross oversimplification and it would probably take roughly 2s to shoot holes in it but I like simple things and I like buckets so there you go. The Expression tools are currently at version 2 (in fact most, if not all, are v2 Sp1). Version 3 is imminent.
Expression Studio is the daddy. It contains the suite of Expression tools including Design, Web, Media, Blend, Encoder as well as a copy of Visual Studio Standard edition. It currently retails for a little over £400. It’s also possible to buy an Expression Professional Subscription which (a bit like MSDN) gives you access to other products and services (eg operating systems and support incidents) in addition to the Expression Studio products.
Expression Design is an illustration and graphic design tool that is conversant in XAML. It’s therefore very useful for creating assets for Silverlight and WPF applications. You can import from a wide range of formats including Illustrator and Photoshop and export to image formats such as PNG, JPG etc as well as XAML, PSD and PDF. Expression Design is part of Expression Studio.
Expression Web is our web design tool. Very much focussed on web standards and standard based design, it has great support for ASP.NET and PHP as well as some very powerful reporting tools and great CSS visualisation. Expression Web 1.0 replaced FrontPage in 2006. Expression Web retails for about £175.
Expression Media is an asset managing tool for cataloguing digital assets and organising them for easy retrieval. I’m beginning to think this exactly the sort of tool I need for all the video and imagery I’ve captured recently. Expression Media retails for about £120.
Expression Blend is perhaps the trickiest Expression product to visualise until you’ve used it. It’s all about making it easy to create the interactive, dynamic experiences that are possible with Silverlight and WPF. Think about animations, styling, transitions, layout etc etc. Essentially it’s a very powerful visual designer that transforms your design into the equivalent XAML representation. It’s a must if you’re building complex Silverlight or WPF applications designs. Expression Blend retails for just under £300.
Expression Encoder is a video encoding / transcoding tool that can also generate a Silverlight media player experience. It is generally used for transcoding to Silverlight compatible (ie VC-1) formats although it’s be no means limited to that. It’s also useful for transcoding to device friendly formats / resolutions. It retails for about £120.
This is how things stand today and of course is all subject to change with the release of Expression 3. I’ll follow up with some more details and jump-start information on Expression Design, Web, Blend and Encoder.
I’ve realised that despite all the noise about it, I’ve pretty much managed to ignore the Web Platform Installer (WebPI) to date. Which is a shame because I know it does some pretty cool things, takes a lot of the drudgery out of
configuring your machine and, from today, I’m actually convinced that I would use it myself even though I’m pretty comfortable setting up my dev environment on a new box. (when I say a new box I really mean the same box fdisk’d. I like to think of that as new box so my satisfaction levels aren’t dependent on fickle things like capex budgets).
When you visit the download page, you’ll see two versions available. There’s the boring-but-safe released version 1.0 or the racey, throw-caution-to-the-wind 2.0 Beta. I of course went with 2.0 Beta as I’ve nothing-to-lose (and I was installing in a freshly-created, just for this purpose VM).
Enough with the hyphen-fest already!
The Web Platform Installer is a simple, integrated way to download, install and configure the Microsoft web platform (ie IIS, SQL Server Express, .NET Fx, VWD etc) and popular open source web apps. Nifty.
It’ll even install and configure PHP for you if that’s your thing and, of course, PHP runs great on IIS with IIS7’s FastCGI support. This saves you wading through this article or watching these videos that I made explaining how to do this.
When you fire up the WebPI 2.0 Beta you’re presented with 3 vertical tabs. Personally, I found it more intuitive to start on tab “2” and decide which core platform elements I wanted. I opted for all of them. Why not?

Tab 3 lets you choose any application you want to install. There’s a mix of ASP.NET and PHP applications. The Web PI is pretty good at warning you about dependencies but clearly if you’re adding an ASP.NET app you’re going to need to enabled to ASP.NET platform components and the same goes for PHP.

Having tackled tabs 2 & 3, tab 1 lets me choose any other “bits” I want to install. I opted for PHP and the SQL Server driver for PHP (oh yes, just because you’re doing some PHP it doesn’t mean you can’t enjoy the loveliness that is SQL Server) as well as SQL Server Express, the SQL management tools, ASP.NET MVC and the SEO Toolkit Beta.
I set things off and it whirled away for a while with a single reboot early on (there were 23 separate packages downloading, installing and configuring). As it turned out, PHP failed to install due to a signature verification issue and therefore the SQL Server driver wasn’t installed either. I simply re-ran the install and both installed fine.
Now to employ my PHP ninja skills and deploy the page to my IIS root directory \inetpub\wwwroot.
And, amazingly (and I was genuinely quite surprised) it worked first time. I had no config to do – that was all taken care of by the Web PI.
For ASP.NET, either make sure you configure this via the WebPI (Web Platform tab – Web Server – Customize) which saves you messing about in Server Manager afterwards. Or do it through Server Manager in WS2008 (Control Panel – Programs – Turn Windows Features On / Off in Vista / Win7) by configuring the Web Server role.

Finally I checked that Visual Web Developer worked. It did.

And that SQL Server Express worked. It did.
Overall I’m mightily impressed and I wasn’t even installing any apps. If I also wanted WordPress or DotNetNuke or Drupal etc this would save me a huge amount of time. I still have to play with some of the components (in particular the SEO toolkit) but from what I’ve seen I really like the WebPI.
Technorati Tags:
asp.net,
iis,
php,
webpi
I’d seen this video (as I said to Mark, I find the start a bit creepy) before I saw Mark’s blog post on the subject (which he wrote some time back). It’s a proof of concept focussing on transport and the challenges we all face when negotiating our way around the cities where we live and the cities we visit. How should I get there? Where should I park? Can I drop the car here and walk. Perhaps I should get the bus? Why don’t we have some sort of integrated transport information network?
This proof of concept was part of the “Intelligent City” programme, a Birmingham City wide initiative to “address key urban issues relating to transport, tourism, security and climate change through the exploitation of information technology”. I should just encourage you to read Mark’s blog post as he has all the interesting details.
As for the video, I found the choice of mobile device interesting. Personally, I’d have gone for something a little more compact rather than something the size of a bus shelter but that’s just me. More interesting (and serious) though is the service platform at the heart of all this based on WCF and SQL Server 2008. This allowed the team to build a variety of client applications and leaves the door open for further apps in the future. (Perhaps a Surface app Mark? More portable than your choice of mobile device).
I can’t help but think that a similar system would be ideal for the Tesco flagship store in Slough. If you’ve ever been you’ll know you don’t just need your a SatNav to negotiate the car park but an aerial view of the available spaces to have any hope of getting one.
Apologies if I’ve mentioned this before – I don’t recall doing so but that doesn’t count for much these days! I came across the ASP.NET MVC Training Kit (actually, Mark Quirk put me on to it). According to the blurb “The ASP.NET MVC Training Kit includes presentations, hands-on labs, demos, and event materials. This content is designed to help you learn how to utilize ASP.NET MVC”.
As you can probably tell I’m posting this before I’ve actually downloaded it but that’s my next stop…
Download the ASP.NET MVC Training Kit
Technorati Tags:
asp.net,
asp.net mvc
RampUp is a community based learning programme created by a plethora of well respected subject matter experts that currently offers track on the likes of
:
- Developer Basics
- Web Development with ASP.NET
- Move from ASP to ASP.NET
- Move from PHP to ASP.NET
- Develop Windows Mobile 6 Applications
- SharePoint for Developers
- and many more
Best of all it’s free – just click on a track to sign-up and get started.
Sounds like a great deal to me.
At last year’s Remix:UK conference in Brighton, ScottGu mentioned a local company called Jump the Gun who were running their online store on ASP.NET MVC well before we’d released it. Wanting to chat to a local company who’d chosen to build ASP.NET MVC applications, I recently did a bit of research and discovered that the Jump the Gun site is running on an open source eCommerce app called Suteki Shop developed by Brighton-based freelance programmer Mike Hadlow.
Earlier this week I travelled down to sunny Brighton to drag Mike away from his desk for a couple of hours for a spot of lunch and a chat about his likes and dislikes in ASP.NET MVC and Webforms, why he built Suteki Shop, his involvement with open source, application architecture and, most importantly, how the heck you’re supposed to pronounce “Suteki”.
The results are lovingly captured in these 2 videos. There is a little bit of overlap between the two – the description will help you pick if you only have time for one of them. NB: the first minute (intro) is the same for both videos.
In this first video we chat about why Webforms vs MVC, what excites Mike about ASP.NET MVC, the architecture and technology choices behind Suteki Shop, the Castle Project’s Windsor IoC container, the “sweet-spot” for MVC and plans for the future.
In this second video we chat about “Suteki” – what it means and how to say it, why Mike created Suteki Shop, how the Jump the Gun site came about, the “long-tail” business, multi-tenancy, what distinguishes Suteki Shop from other eCommerce applications , why he chose to open source it and we get interrupted by a very rude gull.
I mentioned in my Developer Day Scotland session that ASP.NET MVC enjoys the benefits of the underlying ASP.NET platform such as caching, membership, profiles and localization. Guy Smith-Ferrier politely questioned the accuracy of that statement wrt localization (and who am I to argue - Guy knows more about ASP.NET localization than I ever will).
We discussed it over email afterwards and Guy has written up his thoughts on ASP.NET MVC localization on his blog. In fact I’m very comfortable with what I said – and I certainly wasn’t trying to mislead anyone. My point was that the underlying services from ASP.NET are inherited by ASP.NET MVC.
Guy explains in his post that there’s more “manual” work to be done as [a] Visual Studio’s Generate Local Resources function targets ASP.NET server controls (which by and large don’t exist in ASP.NET MVC) so it’s not much use and [b] you need to modify any HTML elements to be HTML server controls (ie add runat=”server”) for ASP.NET localization to target them.
Fair comment. The nature of localization means that we’ve done a lot of work in Visual Studio to take some of the drudgery out of it for ASP.NET webforms and that same capability is not there (not yet at least) for ASP.NET MVC. The platform capability is there, you just have to do more work to make use of it.
A search for “ASP.NET MVC localization” turns up a number of useful articles on the subject (in addition to Guy’s post).
I sat in on a Windows Azure session given by my colleague David Gristwood recently. He talked a great deal about the fundamentals of the Azure platform, the compute and storage capabilities, as well as talking about other components such as SQL Services and .NET Services. At one point he played a short video showing integration between an application running on Windows Azure and another running on Google App Engine. Interesting stuff but David didn’t have the opportunity to drill into any of the implementation details.
It turns out that the demo was built by another colleague Simon Davies who spends a lot of his time with Azure. Simon has just posted more details of the demo (and the video) to his blog. This is really an exploration of the capabilities of the .NET Service Bus. Simon says:
“…My intention was to show off a couple of aspects of Azure. Firstly the emergence of cloud computing not only creates an opportunity for the use of the cloud as a place to execute applications – in our case Windows Azure - but in addition provides the opportunity to provide services that developers can take advantage of in their applications, regardless of where those applications are running. Second I wanted to show off the fact that these services are – and need to be - interoperable with services and applications on other platforms.”
You can read the full article over on Simon’s blog.
I recently dragged colleague Mark Bloodworth out to the lake at TVP to chat about ASP.NET MVC and working on a proof of concept with iWantGreatCare.org, a free service for those looking to find the best healthcare for themselves, their family or those they look after.
I was particularly interested in the migration from Ruby on Rails (from around 4.00) and the extensibility that ASP.NET MVC offers – Mark talks about easily adding mobile support to the app (from around 5.30) and alternatives around this.