Reflector Giveaway Wrap Up

by DanM 4. March 2011 14:00

Well, all 50 Reflector 7 VS Pro licences have been sent off to their new owners. Thank you to everyone who entered and to those of you who didn’t, well it may have been worth your while to jot down some notes. First some stats about the giveaway.

The giveaway started on Friday Feb 11 and was publicized almost exclusively by twitter and those reading my RSS feed. Key people like Scott Hanselman and Jon Skeet retweeted its existence which helped no end, with 804 day 1 page views to the giveaway entry by the end of play. Chris Alcock was also kind enough to point out the giveaway the following Monday leading to another spike in interest of 204 page views that day. In total, there were some 1990 page views between start and finish of the giveaway with 1866 unique views according to Google Analytics.

So nearly 2000 people read about it and yet only sixty (yes, 60) people entered. You missed a great chance here everyone.

So What Is It Used For?

From those entries received, it seems that the most popular use for reflector is trying to figure out how Microsoft’s own code works. As one entrant wrote,

I am a SharePoint Developer.  ‘nuff said.

Indeed, this was not the only SharePoint developer entering the giveaway, although it was definitely the most succinct. Here’s a full list of those DLLs and applications that were mentioned in entries.

  • .NET Framework (unspecified) – 16
  • Non-MS Third Party Components – 9
  • ASP.NET – 7
  • SharePoint – 2
  • MS Dynamics – 2
  • WCF - 1
  • WPF – 1
  • Surface SDK – 1
  • Expression Blend – 1
  • Azure SDK 1.3 - 1
  • PowerGUI - 1
  • Telerik Sitefinity – 1
  • nHibernate – 1
  • MS Commerce Server – 1
  • MS Unlocker for WinPhone7 \ ChevronWP7 Unlocker – 1

Granted sixty people isn’t very representative of all developers out there, but maybe Microsoft are realising there is actually a call for good API docs and in-depth articles on how stuff works. I noticed that the ADO.NET team mentioned this apropos the forthcoming release of Entity Framework 4.1

We’ve held off on extensively documenting the CTPs because the API surface has been changing so much. RC will have intellisense and online documentation.

Something that Microsoft.Web.Helpers could do with for sure.

But figuring out a third-party DLL isn’t the only reason for using reflector. A number of you replied that Reflector had saved the day after a hard drive crash or disaster by source control failure of some kind. CW for example wrote,

I walked in to a new job a couple of years ago, within a few days I noticed that they had an issue with version control. There were 3 VSS databases and some other guy had decided to use CVS – just to add to the mix.

It became clear that the ‘old’ developers were happy with VSS and when it got a bit slow or crashed too much they would just setup a new VSS databases do some copy / paste of files and carry on. The CVS guy knew this was all bad and was trying to force everyone to ditch VSS and move to CVS. To add to the fun people had not used labels in VSS and there was also a culture of checking-in weeks or months after something was put into prod.

So – trying to work out where the current production code was held – or IF it was even held was a nightmare. Luckily for me everything was C# and they had not obfuscated any code.

Reflector to the rescue – every time I needed to make a change in production to something I had not worked on before I would reflect the current production binaries and then compare with what I could find in VSS or CVS. Even 3 years later I am still finding odd bits of code that I need to reflect – none of this would have been possible without Reflector.

Several entries also highlighted one or several of the plug-ins that Reflector now has via http://reflectoraddins.codeplex.com/ and the integration into Visual Studio that the recent Pro versions of Reflector have included.

Reflector has also used in a couple of more innovative ways by entrants.

  • It disassembles IL code back into C#, so a few developers use it to translate their VB code into C#.
  • As an obfuscation check. If Reflector crashes while trying to disassemble a DLL’s code, the developer takes it to mean that they have a good level of obfuscation applied to their code to hide it from casually prying eyes.

And to conclude, here is a list of useful projects that reflector has influenced and helped:

Reflector 7 Giveaway

by DanM 11. February 2011 11:00

There’s been a great deal of discussion online recently about Redgate Software's decision to move their stewardship of Lutz Roeder’s Reflector software from a free \ premium model to a not-free \ premium model. The company’s Reflector forum is full of pleads, cajoles, reasonings and answers as to why a Reflector 7 licence will cost you $35 rather than $0 for v6. But when you come down to it, if you use Reflector in anger - and I’m sure many of us do – $35 is a small price to pay for the fantastic functionality it provides. And if you don’t already use it, then maybe I can help out.

Back on Feb 3, Jay Grieves bought ten Reflector 7 licenses with his own money to give them away. Redgate saw the post and offered another 50 licenses for his giveaway. If you didn’t notice it, that giveaway ends today so I’ve got in touch with Redgate and they’ve agreed to give me another 50 licenses to give away. However, rather than just post a comment below, I’d like to help others appreciate how useful Reflector can be.

So, please email me your favourite use for Reflector with examples and screenshots if you have the time and fifty people who send an email will get a Reflector 7 license free of charge. The address to send it to is HeresWhyILove-Reflector@yahoo.co.uk and the deadline is Monday February 28. I’ll post the best and most popular examples here next month.

Good luck

Three Changes of Behaviour in AJAX Control Toolkit v40412

by DanM 13. August 2010 16:00

The interesting thing about writing a book such as Programming ASP.NET 3.5 is that as new readers come to it over time, they find that libraries used within the book code break the examples. Peter Ormshaw got in touch today to point out that the Ajax Control Toolkit has changed slightly since build 20229 which the book was built against.

In particular, he’s come across three differences between the book and working with v3.5.40412 which is the latest version at the moment.

Installing The Control Toolkit

Appendix A, which covers installing the control toolkit is now obsolete. Best practice now would be to download the binaries for the toolkit and follow the installation instructions at http://www.asp.net/ajaxlibrary/act.ashx.

You Must Use The Toolkit Script Manager

Any AJAX web form you’ve created in Visual Studio automatically contains the standard ASP.NET ScriptManager control. If you want to use any toolkit controls on that page, you must replace this with the toolkit’s own ScriptManager control. So then, you change this

<asp:ScriptManager ID="ScriptManager1" runat="server" />

to this

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>

Toolkit now uses asp as its TagPrefix: BulletedList Users Beware!

The final thing to note is that v40412 now has the Toolkit controls use “asp” as the default TagPrefix for its controls rather than cc1. This in itself is not a problem and makes sense as Microsoft have now more formally adopted the Toolkit with all its jQuery finery and finessing on the client side.

However, the toolkit also includes a control called BulletedList which, with the tagprefix change now means that Visual Studio will no longer compile pages referencing the toolkit and containing this control until you alter the TagPrefix used by the toolkit on that page. Typically, that means changing the “asp” in TagPrefix=”asp” in this line

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

to something other than asp. Don Kiely has a full description and reasoning behind this issue at devproconnections.com.

CSS3, Round Corners, Webforms and IE

by DanM 13. April 2010 22:30

This article looks at the best methods I've found and lessons I've learned trying to style various HTML elements consistently with rounded corners. As with all articles of this type, your mileage may vary.

I don't know about you, but as an ASP.NET Webforms developer one of the first things I look for when a designer sends me a new look for a site I'm working on is the presence of rounded corners. Switching between square and round corners in photoshop or illustrator is done with the click of a button. In HTML, there's a little more effort involved. How much depends on

  • What range of browsers are being targeted
  • Whether or not I need to inject additional HTML into the markup generated by my webform controls. Will I end creating a user control to keep generating the correct HTML for the technique?
  • How many additional images I'll need to create to get it working
  • Will I need to use some javascript (jQuery etc) in the technique and slow the total page load time further?

For example, let's assume we have three nesting block-level elements (a form, and 2 divs) and three buttons (an input element, a link as a button and a button elements) inside the inner div

  • The form and outer div will both have rounded corners of radius 25px and 20px respectively.
  • The inner div will have rounded corners top left and bottom right of 15px radius.
  • The three buttons should have rounded corners of 10px radius.
<%@ Page Language="C#" AutoEventWireup="true"  
    CodeFile="css3.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">  
  <title>Rounded Corners</title>
</head>
<body>
  <form id="a" runat="server">
  <div id="b">
    <div id="c">
      <p>This is an &lt;input&gt; button -  &lt;asp:button&gt;: 
        <asp:Button runat="server" ID="testInputButton" 
          CssClass="button" Text="Input Button" /></p>
      <p>This is an &lt;a&gt; tag - &lt;asp:linkbutton&gt;: 
        <asp:LinkButton runat="server" ID="testLinkButton" 
          CssClass="button">Link Button</asp:LinkButton></p>
      <p>This is a &lt;button&gt; tag: 
        <button runat="server" id="testHtmlButton" 
          class="button">Html Button</button></p>
    </div>
  </div>
  </form>
</body>
</html>

Ideally of course, we should be starting to use CSS3. The border-radius property is custom-made for rounding the corners of any element. Adding a few rules like the ones below - not forgetting the -moz-border-radius and -webkit-border-radius equivalent properties as Firefox and Safari don't directly support border-radius itself yet - and we get pretty good results.

html
{
   background-color: #004;
   font-family: Calibri;
}
#a
{
   width: 500px;
   margin: 25px auto;
   padding: 25px;
   background-color: #888;
   border-radius: 25px;
   -moz-border-radius: 25px;
   -webkit-border-radius: 25px;
}
#b
{
   padding: 25px;
   background-color: #00c;
   border-radius: 20px;
   -moz-border-radius: 20px;
   -webkit-border-radius: 20px;
}
#c
{
   background-color: #fff;
   border-radius: 15px 0 15px 0;
   -moz-border-radius: 15px 0 15px 0;
   -webkit-border-radius: 15px 0 15px 0;
}
p
{
   padding: 10px;
}
.button
{
   background-color: #ccc;
   padding: 10px;
   border-radius: 10px;
   -moz-border-radius: 10px;
   -webkit-border-radius: 10px;
}
That bit of CSS renders the page correctly in Chrome 4 and 5, Safari 3 and Firefox 3.6.

CSS3 in Action

In Opera 10.51, <input> and <button> don't get rounded corners, and to give it credit, the current IE9 preview rounds everything save the Link Button as well, but it's IE8 and older which cause the problems, steadfastly refusing to do anything at all. There are many - and I do mean, many - CSS solutions to do away with IE's sharp corner fixation. Some involve lots of images, some use javascript and some both.

After trying pretty much all of them over the past few days, here are some thoughts.

  • No one of these techniques works satisfactorily on both block-level and button elements - out of the box anyway. And unless you feel confident working with some of the javascript-based techniques, that means you'll need to incorporate one technique for divs and the other for the buttons.
  • The <input> element is incredibly intransigent as far as styling goes in IE. The path of least resistance is to prefer using <button runat="server" onserverclick="handler"> to <asp:Button> wherever possible. The only exception to this is when you want to use a CommandName property on the button. In this case, you can use an <asp:LinkButton> instead.
  • The most backward-compatible techniques seem to be those that were originally created around IE7 time and have been built-upon since. Many of the button-rounding techniques are based on the sliding doors technique first documented here and here on A List Apart back in October 2003.
  • A lot of these techniques use several images. Some already combine all these images into one 'sprite' to improve performance, implying that it's more than possible to do the same with the others too. Automatically bundling CSS images into sprites looks to be one of the items being investigated for ASP.NET vNext. Perhaps we may be able to leverage these automation with these techniques in years to come.

And here are the two techniques that are now secured in my toolbox for the time being.

For Rounded DIVs - CurvyCorners

Curvy Corners (www.curvycorners.net) is a simple Javascript library, actively maintained and updated for new browser versions as they appear. It comes in a plain Javascript and jQuery variants, the latter as a reaction to the work done on the former.

Once you've downloaded it, you can round the corners of DIVs by either calling the javascript library explicitly, like this

<script type="text/JavaScript"> 
  addEvent(window, 'load', initCorners);
 
  function initCorners() {
    var settings = {
      tl: { radius: 25 },
      tr: { radius: 25 },
      bl: { radius: 25 },
      br: { radius: 25 },
      antiAlias: true
    }
     curvyCorners(settings, "#a");
  }
</script> 

or, more excitingly, it also works as a frictionless library. Just make a reference to the curvycorners.js in your page and when the page loads, it will look for the CSS3 -webkit-border-radius properties on divs and use them as cues to do its thing. Crucially, it detects first whether or not your browser supports the CSS3 border-radius property (or its -moz or -webkit reflections) and works its magic only if the browser does not - i.e. if your browser is IE8-, Firefox 2-, Chrome 2-, or Opera 9-.

There are naturally, some limitations... And I quote

Because of the need for the mechanism to operate across all browsers, the CSS selector syntax supported is necessarily limited. This sets out what is supported:

  • a selector-list, where a selector-list is either a single selector or a single selector followed by a comma and an optional space, followed by a selector-list.
  • A single selector may be either a simple-selector or a simple-selector followed by a space followed by another simple-selector.
  • A simple-selector may be either an ID of the form #myID, or a tag-class-selector.
  • A tag-class-selector may be any one of:
    1. a tag name (e.g. div);
    2. a class name preceded by a dot (e.g. .myClass); or
    3. a tag name followed by a dot followed by a class name (e.g. div.myClass).

The following are examples of supported selectors:

  • .myclass
  • #mydiv frameset.myclass
  • form.rounded frameset,div.rounded

Warning: because CurvyCorners appends extra DIVs to the boxes you wish to round, the following selector will reliably not work:

#myBox div

This is because the style will be applied not just to the top-level DIVs within the element whose ID is myBox, but also to the DIVs inserted by CurvyCorners.

The following selectors may not work as expected:

  • div #mybox
  • div.rounded #mybox

Because an ID identifies a page element uniquely, qualifying it with an enclosing scope may cause the selector to fail (e.g. if #mybox is a top-level DIV, or if it is not located within a DIV of class rounded). However, CurvyCorners assumes that the element is to be referenced anyway and will apply the appropriate rounding styles.

But it is otherwise a pretty solid thing and, obviously, easy to disable - just remove the js file reference from the page.

For Rounded Buttons - Simply-Buttons

Simply-Buttons (http://www.p51labs.com/simply-buttons-v2/) is one of the aforementioned sliding doors technique, so fully CSS-based using two image for left and right sides of the button with enough hacks to produce the same result for LinkButtons and <button>s in all browsers back to IE6. In addition, should you need your buttons to react to a click or a hover event, it also proffers a small javascript routine which allows you to set additional images to reflect those events.

The demonstration code on the site also shows how to embed icons into your buttons for a better UI feel.

SimplyButtons

What's nice about Simply-Buttons is the flexibility it offers. As far as additional HTML goes, all you need add are two nested <span> elements to your button. This means the technique would be invalid with <input> buttons but as noted earlier, a combination of <asp:LinkButton> and <button runat="server"> tags as replacement work just as well.

<asp:LinkButton runat="server" ID="testLinkButton" 
  CssClass="button">
  <span><span>Link Button</span></span>
</asp:LinkButton>

<button runat="server" id="testHtmlButton" class="button">
  <span><span>Html Button</span></span>
</button>

The download contains the stylesheet that makes the buttons so well. Once you've created the left and right images for your buttons, you need to adjust four well-identified CSS properties in the stylesheet to match the height of the button with the height of the image et voila.

Should you need the hover and click actions for the button, you create the rest of the images to reflect those states (find a good tutorial for creating round buttons here and rectangular ones here) and add the javascript file to your page.

<link rel="stylesheet" type="text/css" href="stylesheets/SimplyButtons.css" media="screen" />
<script type="text/javascript" src="SimplyButtons.js"></script>
<script type="text/javascript">
  window.onload = function()
  {
    SimplyButtons.init();
  };
</script>

The included stylesheet includes styles for both link buttons and html buttons, the iconized buttons shown above and for the hover and clicked pseudo-selectors, so you can cut it down a fair amount as well. All in all, it's a great tool to add to your basket.

Summary

In this article, I've outlined my two preferred methods for incorporating rounded corners into my ASP.NET web sites. Both are are almost frictionless as far as the original asp.net page goes with the only significant restriction being the inability to use <asp:Button> with simply-buttons. However, html\asp.net provides a complete alternative for this so it is a viable option. As ever, your mileage may vary, but it works for me :-)

Happy coding!

ASP.NET 4.0 Part 15, Data Enhancements

by DanM 7. April 2010 23:00

Welcome to part 15 of my tour through ASP.NET 4.0. In this episode, we're going to look at how webforms developers can make more use of both Dynamic Data 4.0 and Entity Framework 4.0 thanks to several new features baked into ASP.NET 4.0.

For those of you unfamiliar with these two products, Entity Framework is the 'enterprise-level' data modeller (O/RM) technology, aimed at larger applications where LINQ2SQL was aimed at small ones. Dynamic Data meanwhile is a rapid development tool used to create a basic scaffolding for a website based on the schema of the database that supports. Almost a CSS-like construct based on the type of data in a field rather than the type,class or id of an HTML element.

It's odd how both Dynamic Data (DynData) and the Entity Framework (EF)  were both released in .NET 3.5 SP1 almost as a tester to garner public reaction to Microsoft's efforts thus far with both projects. And it's fair to say that mistakes / omissions were made in those v1 releases which are now being corrected. EF was vilified in comparison to other, more mature OR/M frameworks for many reasons including

  • Short list of shortcomings that have been fixed in EF 4
  • Unit testing shortfalls. EF objects couldn't be generated as plain old CLR objects (POCOs) - they had to be classes derived from EntityObject which meant they would hit the db when tests were run against them.
  • EF didn't support many to many relationships

DynData, which sat on top of EF, suffered from both EF's shortcomings and some of its own including.

  • DynData 3.5 required you to start a new project and coudn't easily be integrated into a webforms or MVC application
  • If you used EF as the data model, DynData couldn't tell which field in a database table was the primary key and would model it as an editable field. You had to go into the model and annotate it separately.
  • Scaffolding templates for only basic field types and none for entities (types defined across several table joins)

Needless to say, both DynData 4.0 and EF 4.0 address these issues and many more. It's now fair to say that both technologies are well beyond where their first versions perceptibly fell short.

EnableDynamicData

One of the goals of ASP.NET 4.0 was to make DynData's scaffolding available to both Webforms and MVC. As noted earlier, DynData v1 was a project of its own that couldn't be easily retrofitted into an existing website, be it using Webforms or MVC. To remedy this, ASP.NET 4.0 now includes a new method called EnableDynamicData that you can use on any page in a website or web application.

Consider the scenario where you've a FormView or GridView allowing you to update, add to or delete records from a database. Typically, the controls auto-generate columns containing textboxes and maybe a checkbox. Users can add in invalid text, dates, values outside desired ranges etc. So you disable auto-generation and template the columns yourself with a calendar control for dates, say, and validation controls. And then you do the same thing for various other data-bound controls based on the same tables of data. Rather than setting all columns and rows yourself on each control, the EnableDynamicData method tells ASP.NET to generate those customized input and validation controls itself using the DynData scaffolding generated against the database and annotations you may give it as a (central) template.

Let's take an example.

  • Open VS2010 and create a new, empty web site.
  • If you’re using SQL Express, add an App_Data folder and add in the AdventureWorksLT database. You’ll find it for download on codeplex.
  • Add add an Entity Data Model to your site. Generate it from the tables in the newly added database.
  • Add a new page to your site and place on it an EntityDataSource and a GridView. The EntityDataSource should retrieve the EntitySet for the Products table. The GridView should use the EntityDataSource and both should have Update and Deletes enabled.

Your page code should look like this.

<%@ Page Language="C#" AutoEventWireup="true" 
         CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
  <title>Demo</title>
</head>
<body>
  <form id="form1" runat="server">
  <div>
    <asp:GridView runat="server" DataSourceID="entityDs" ID="gvwProducts">
      <Columns>
        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
      </Columns>
    </asp:GridView>
    <asp:EntityDataSource runat="server" ID="entityDs" 
         ConnectionString="name=AdventureWorksLT2008_DataEntities" 
         DefaultContainerName="AdventureWorksLT2008_DataEntities" 
         EnableDelete="True" EnableFlattening="False" 
         EnableUpdate="True" EntitySetName="Products"
         EntityTypeFilter="Product"> </asp:EntityDataSource>   
    </div>
  </form>
</body>
</html>

If you run this page and try to update any of the currency-based fields for an item now listed in the grid (eg. StandardCost or ListPrice) with a non-currency value such as the string ‘abc’, you’ll get the following Yellow Screen Of Death message.

Error while setting property 'StandardCost': 'Cannot convert the value of parameter 'StandardCost' to the type 'System.Decimal'.'.

Of course, if we were to manually generate the columns in the GridView, we could add in validation to ensure that only valid currency values are sent to the database. But let’s not and enable the dynamic data framework on the GridView and see what happens. It’s a single line of code added to your page’s codebehind.

public partial class _Default : System.Web.UI.Page
{
  protected void Page_Init(object sender, EventArgs e)
  {
    gvwProducts.EnableDynamicData(typeof(AdventureWorksLT_DataModel.Product));
  }
}

If you run the page again and try to make the same page, you’ll see that some validation is performed pre-save and so clicking Update on the grid doesn’t produce the previously seen yellow screen of death.

Simple Validation

Admittedly, it’s not earth-shatteringly useful as the invalid value is simply highlighted by an asterisk to its side with the actual error message that StandardCost is a required value hidden in a tooltip, but by adding a ValidationSummary control to the page, things become much clearer. And we’re leveraging the Dynamic Data framework to generate validation for us, which we can always amp up by adding instructions centrally to the entity model such as an appropriate error message. For example,

namespace AdventureWorksLT_DataModel
{
  [MetadataType(typeof(ProductMetadata))]
  public partial class Product
  {  }

  public class ProductMetadata
  {
    [RegularExpression(@"^[0-9]{1,}\.[0-9]{2}$", 
       ErrorMessage="Value should be greater than 0.00")]
    public decimal StandardCost { get; set; }
  }
}

Run the page again and you’ll see that a RegularExpressionValidator is now added to the RequiredFieldValidator already there.

There are loads of new features in Dynamic Data 4.0 that we can now leverage in WebForms and MVC including. 

  • Primary keys are now identified as primary keys and are not shown as an editable field
  • New field templates for URLs and email addresses.
  • Many-to-many relationships are now handled as a field template

Entity templates are another new feature in Dynamic Data 4.0. Whereas field templates deal with single field types, entity templates deal with objects as a whole, be they contained in a single table or spanned across many. Let's say we've a website in which the information for an auction item is restricted based on whether you're an admin, the seller or a buyer. An entity template means you can control what each role sees at the object level rather than reiterating it across several pages where that object is bound to controls.

Entity and field templates are available to both MVC and Webforms.

QueryExtender

If there's one problem with LINQ-based DataSource controls (for example, LinqDataSource and EntityDataSource) in .NET 3.5 it's that filtering on the data isn't supported declaratively by the data source. You have to take control of the query being sent to the database, add the filtering yourself and then passing the query back to the data source, usually by handling the OnQueryCreated event.

protected void dsProducts_QueryCreated(object sender, QueryCreatedEventArgs e)
{
  if (!String.IsNullOrWhiteSpace(txtFilterName.Text))
  {
    e.Query = from p in e.Query.Cast<AdventureWorksLT_DataModel.Product>()
              where p.Name.StartsWith(txtFilterName.Text.Trim())
              select p;
  }
}

In .NET 4.0 however, there is now a solution - the new QueryExtender control. Let's take an example and reuse the page we've got going. It already pulls down the contents of the Products table from the AdventureWorks table. Let's add a simple textbox which let's you set the start of the product's name to search for.

<body>
  <form id="form1" runat="server">
  <div>
    Name starts with:
    <asp:TextBox ID="txtFilterName" runat="server">Sport</asp:TextBox>
    <asp:Button ID="btnGo" runat="server" Text="Go" />
    <br />
    <asp:GridView runat="server" DataSourceID="entityDs" ID="gvwProducts">
...

To include the filtering in the page, we add the QueryExtender to the page as follows.

<asp:QueryExtender runat="server" ID="qeFilter" TargetControlID="entityDs">
  <asp:SearchExpression DataFields="Name" SearchType="StartsWith">
    <asp:ControlParameter ControlID="txtFilterName" PropertyName="Text" />
  </asp:SearchExpression>
</asp:QueryExtender>

Et voila. As the page loads, the QueryExtender informs the EntityDataSource and filters the data it presents us based on the contents of the text box.

Summary

There's a heck of a lot of new and interesting stuff going on in and around the world of data in .NET. Besides the advancements to the Dynamic Data and Entity Frameworks, there's also a new version of ADO Data Services (now known as WCF data services), the introduction of data storage in the cloud with SQL Azure Services and client-side data binding with AJAX Data Templates.

In our look at one small corner of it all, we saw how the EnableDynamicData method allows us to leverage the Dynamic Data Framework to act as a CSS-like form presentation and validation rules template for all our templated, data bound controls - a level of integration between Dynamic Data and Webforms/MVC previously unavailable.

We also saw how we can leverage the new QueryExtender control against LinqDataSource and EntityDataSource controls to act as dynamic filters for the data they retrieve.