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.

<add tagPrefix="asp" namespace="System.Web.UI.WebControls.Expressions" assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

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 <pages><controls>..</controls></pages> tags in the web.config file.  Post this, you would also be able to get intellisense for these within the QueryExtender

Cheers !!!

Print | posted on Thursday, June 4, 2009 5:46 PM

Comments on this post

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

Requesting Gravatar...
Cool. Thanks for sharing. christian louboutin shoes
Left by Alam on Apr 09, 2010 3:21 PM

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

Requesting Gravatar...
You won’t even get intellisense for the above inside the QueryExtender tag.
Left by Noni mehu on May 02, 2010 4:25 AM

Your comment:

 (will show your gravatar)