Namespace Problem

Posted by Tarik on Stack Overflow See other posts from Stack Overflow or by Tarik
Published on 2010-04-07T16:39:41Z Indexed on 2010/04/07 16:43 UTC
Read the original article Hit count: 417

Filed under:
|
|

Hello,

Normally we all do use using System.Linq; and using System.Data.Linq; for example on the code-behind and expect we can reach the members of these namespaces from Source Code like <%= Something.First()%> but when I wrote it, asp.net said it couldn't find First() in the context and I had to add <%@ Import Namespace="System.Linq" which looked very weird to me but it worked out. Since they are targeting at the same class why they both need separate namespace importing.

Code-behind :

using System;
using System.Data.Linq;
using System.Linq;
using System.Text

namespace Something
{
   class Items : System.Web.UI
   {
       //...
   }

}

but also I need to add the same Linq namespace on the Html Source part

<%@Import Namespace="System.Linq"%>

Do I know something wrong or this is some kind of bug in asp.net. I thought when the page is compiling, asp.net combines these two classes and converts html source code into cs class and indicates the control in Control c= new Control(); hierarchy.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about namespace