Pgae Directive


J

Jim Heavey

Is the Page directive only go on ".aspx" pages? I think the answer is yes,
but I am not positive. I am trying to figure out why a called class can not
be found and I was wondering if I should place a page directive on the class
which I am trying to call.

In my situation I have "MyPage.aspx" which has code behind page called
"MyPage.aspx.vb" and "MyPage.aspx.vb" instatiates "Myclass.vb" and the
"MyClass.vb" can not be found. All my code is source code, not compiled code,
so I am using the page directive of @Page Inherits="MyPage"
src="MyPage.aspx.vb". When "MyPage.aspx.vb" instatiates "MyClass.vb" it fails
with a compile error.

I have taken the "MyClass.vb" and created a new project and compiled the code
as a new project and placed that dll into the bin folder, but then I get an
error of "Invalid Type" when the class is instatiated.

I have tried using the @Assembly directive of @Assembly src="MyClass.vb", but
this has no effect.

How can I resolve this error allowing the source code to be compiled on the
fly?
 
Ad

Advertisements

J

Jerry III

First, yes, the page directive is only good in ASPX pages. Second, you can't
reference code behind pages from other code behind pages without compiling
them. You either have to put all of that code in one file or you have to
write it so it doesn't reference each other. Or you have to compile all but
one and put the compiled code in the /bin directory.

Jerry
 
J

Jim Heavey

Then what is the purpose of the "<%@ Assembly" directive?
That directive allows you to link together application and
it as a "src=" option which seems to imply that you can
have strait source rather then compiled code.

Am I missing something?
 
J

Jerry III

You're missing the fact that the assembly will only be visible in the page
that contains the directive, but not in other assemblies you include in the
same page. To have the assemblies see each other you have to compile them
and use Using Assembly.Name (in C#) within the assembly files.

Jerry
 
Ad

Advertisements

J

Jalil Vaidya

I hope I understood you question correctly. To use the class, you will
have to Import the namespace that the class is in. If the class is in a
DLL then you will have to add it to the references of the project.

Jalil Vaidya
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top