How do I use Import or Inherits on a Single Page .aspx Page

  • Thread starter Christian Blackburn
  • Start date
C

Christian Blackburn

Hi Gang,

I have trouble getting my single page Aspx pages to allow the imports
and or inherits command. Can someone reply with an example.

Thanks,
Christian Blackburn
 
J

Jim Wooley

Import and Inherit are very different animals.

Imports is like a big With statement for your current file. It brings a namespace
into scope so that you can use it without having to fully qualify the name
you are using. You specify the imports at the very top of your code.

Inherits means that you want your new class to be based on the class you
are inheriting from. Inherits are placed on the class not on the file, thus
it should be the first line after your class declaration. You can only inherit
from one class because a thing can only be one thing ("is a" relationship).
It may contain many things ("has a" relationship) which is where interfaces
come in.

Since you are working with web applications, your web forms already inherit
from System.Web.UI.Page. It can not directly inherit from something else
as well (although you can subclass that and extend it with your own functionality
if necessary).

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
 

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