Unknown server tag ‘asp:SearchExpression’ error with QueryExtender control in Visual Studio 2010 Beta 1

One of the cool things about ASP.NET 4.0 is the Query Extender and the ability to search within DataContext without using WHERE clause, writing extensive code etc.,  It works on the new set of namespace i.e. “System.Web.UI.WebControls.Expressions” namespace.

I am trying to put up an extensive sample using QueryExtender in the next post, but for this post, I wanted to share an error that you might hit when trying to implement the Query Extender control with Search Expression, Range Expression etc.,  This error is specific to the Visual Studio 2010 Beta 1 build that was released to public.

If you look at the MSDN sample for Query Extender it ports a markup like below for Query Extender

<asp:QueryExtender runat="server" TargetControlID="LinqDataSource1">

     <asp:SearchExpression SearchType="StartsWith" DataFields="Name" >

        <asp:ControlParameter ControlID="SearchTextBox" />

     </asp:SearchExpression>

</asp:QueryExtender>

As you can see, the QueryExtender is useful only when you add SearchExpression etc., since they define the action that QueryExtender performs. However, when you try the above sample with Visual Studio 2010 Beta 1, you might get a build error and/or a runtime error that Unknown server tag ‘asp:SearchExpression’.  The same error occurs for RangeExpression, PropertyExpression etc.,

You won’t even get intellisense for the above inside the QueryExtender tag.

The reason for the same is a simple mismatch in the web.config namespace reference entry.  Once you add the following entry in the web.config file, this error would be gone.

Note: The PublicKeyToken needs to be updated as per the other entries in this section, if different.

The above tag needs to be placed between .. tags in the web.config file.  Post this, you would also be able to get intellisense for these within the QueryExtender

Cheers !!!

This article is part of the GWB Archives. Original Author: Harish Ranganathan

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.