Code behind not in separate file

T

Terry Olsen

I didn't choose "code in separate file" when creating a web page. So I have
to use the fully qualified object names because I can't figure out where, or
even if i can, put the Imports statement. Can anyone shed some light on
this? What are the limitations when you have the server-side code in the
aspx file?
 
M

Masudur

Terry said:
I didn't choose "code in separate file" when creating a web page. So I have
to use the fully qualified object names because I can't figure out where, or
even if i can, put the Imports statement. Can anyone shed some light on
this? What are the limitations when you have the server-side code in the
aspx file?

Hi,

When you are using server side codes in aspx page , you can still use
the import statement but in a different way.

just put the import statement below you page declaration

<%@ Page Language="C#" %>
<%@ Import Namespace="MyPackage.MyNameSpace" %>

thats it...

But its better to use code behind file.

Code behind file is introduced to make your code more maintainable
and separating the code logic from the page helps enforce the MVC
pattern.

Thanks
Masudur
kaz Software Ltd.
www.kaz.com.bd
 
L

Laurent Bugnion

Hi,

Terry said:
I didn't choose "code in separate file" when creating a web page. So I have
to use the fully qualified object names because I can't figure out where, or
even if i can, put the Imports statement. Can anyone shed some light on
this? What are the limitations when you have the server-side code in the
aspx file?

There are many disadvantages to having the code in the ASPX file. First,
you don't have the clean separation between UI and code, then you must
publish the uncompiled code to the server, and finally as you found out,
linking to other libraries is more difficult.

I strongly recommend you to use code-behind files.

HTH,
Laurent
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top