David Wier wrote:
> Put that at the very top of the page, before the Class declaration
>
> David Wier
>
http://aspnet101.com >
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML with no
> bloated markup
>
>
> "Ralph Wiggum" <go.ahead@spam.me> wrote in message
> news:2uidnWsIisuhLQra4p2dnAA@telenor.com...
>> I'm pretty sure the compiler will complain about "using
>> NamespaceInMyOtherClass;" in the code below. How can I tell MyClass to
>> look in the MyOtherClass.cs file?
>>
>> aspx:
>> <%@ Assembly Src="MyClass.cs" %>
>> <%@ Import Namespace="MyClass" %>
>> <%
>> MyClass mc = new MyClass();
>> %>
>>
>> MyClass.cs:
>> namespace MyClass{
>> public class MyClass{
>> using NamespaceInMyOtherClass; <-- Problem!
>> public MyClass(){
>> MyOtherClass moc = new MyOtherClass();
>> }
>> }
>> }
>>
>> MyOtherClass.cs:
>> namespace NamespaceInMyOtherClass{
>> public class MyOtherClass{
>>
>> }
>> }
>>
>>
>>
>> Peter Bromberg [C# MVP] wrote:
>>> MyClass should have a reference to MyOtherClass, and a using statement at
>>> the top of its class file in order to use a namespace defined in
>>> MyOtherClass.cs . You don't need it at the @Page level at all.
>>> -- Peter
>>> Site:
http://www.eggheadcafe.com >>> UnBlog:
http://petesbloggerama.blogspot.com >>> MetaFinder:
http://www.blogmetafinder.com "Ralph Wiggum" wrote:
>>>
>>>> Ok, thanks. But what if the namespace is defined in a separate file,
>>>> MyOtherClass.cs and I need to use it in MyClass.cs:
>>>>
>>>> <%@ Import Namespace="NamespaceInMyOtherClass" %>
>>>> <%@ Assembly Src="MyClass.cs" %>
>>>> <%@ Assembly Src="MyOtherClass.cs" %>
>>>> ....
>>>>
>>>> How can I tell MyClass.cs to import from MyOtherClass.cs when I remove
>>>> the first line above?
>>>>
>>>> David Wier wrote:
>>>>> It's just the basic:
>>>>> Imports System.Collections.Specialized
>>>>>
>>>>> And yes, import it only in the class - it will automatically get
>>>>> referenced in the page, when you instantiate the class.
>>>>>
>>>>> David Wier
>>>>>
http://aspnet101.com >>>>>
http://iWritePro.com - One click PDF, convert .doc/.rtf/.txt to HTML
>>>>> with no bloated markup
>>>>>
>>>>>
>>>>> "Ralph Wiggum" <go.ahead@spam.me> wrote in message
>>>>> news:_L6dnWCRYMOyBwra4p2dnAA@telenor.com...
>>>>>> I have an aspx that looks like this:
>>>>>>
>>>>>> <%@ Import Namespace="System.Collections.Specialized" %>
>>>>>> <%@ Assembly Src="MyClass.cs" %>
>>>>>> ...
>>>>>>
>>>>>> I'm only using the imported namespace in MyClass.cs, not in the aspx
>>>>>> itself. Is it possible to do the import in MyClass.cs, instead of the
>>>>>> aspx? I can't figure out the syntax...
>