Solved

I'm having difficulty understanding page inheritance

Posted on 2008-06-21
8
610 Views
Last Modified: 2013-11-07
Hello all

In an effort to enhance my skillbase I am trying to get to grips with Visual Basic (and C#) ASP .NET programming. All is going well except for this error regarding page inheritance. It has cropped up a few times and I though I'd cracked it with an earlier success, but here it comes again.

I have defined my namespaces (ACS.console) in my app_code/basepage.vb file and imported it appropriately into my master page code behind file. I have defined the master page namespace and the class, and referred to the class correctly in the master page header.

Yet still I have this error. I admit to being a noob at VB.NET so I'm hoping for some sympathetic expert to be gentle with me. :)

Thanks in advance, and here is the code...

~/app_code/basepage.vb

----------------------
 
 

imports system

imports system.web

imports system.web.ui
 

namespace ACS.console
 

	public class basepage

	

		inherits page

		

		...
 

	end class

	

end namespace
 
 
 
 

~/console/console.master

------------------------
 
 

<%@ Master Language="VB" CodeFile="console.master.vb" Inherits="ACS.console.master.mastercode" %>
 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
 

<head>
 

etc. etc.
 
 
 
 

~/console/console.master.vb

---------------------------
 
 

Imports System

Imports System.Xml

Imports System.Web

Imports System.Web.UI

Imports ACS.console
 
 
 
 
 
 

namespace ACS.console.master
 

	public class mastercode

		inherits page

		

		public sub page_load
 

...

Open in new window

0
Comment
Question by:jerute
  • 3
  • 3
8 Comments
 
LVL 18

Accepted Solution

by:
Richard Lee earned 500 total points
Comment Utility
Your question is not entirely clear. What exactly is the error?

One thing I have spotted however is that your master page class is inheriting the Page class; it should inherit the MasterPage class.
0
 

Author Comment

by:jerute
Comment Utility
Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).
0
 
LVL 5

Expert Comment

by:JuckMan
Comment Utility
you need a code behind file only if your want to have server side handling.

If u really want to understand how this works review the article on this link.
http://msdn.microsoft.com/en-us/library/ms178472.aspx

Also note you can sperately create a page class and hook up with any aspx page. In this way you can create a single page class and should be able to use it as a code behind for any aspx page provided you define it in your aspx page and your code behind class..

0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:jerute
Comment Utility
I have got a code behind file (console.master.vb) but co-incidentally I have discovered the solution myself.

Instead of inheriting System.Web.UI.Page it needs to inherit System.Web.UI.Masterpage.
0
 
LVL 18

Expert Comment

by:Richard Lee
Comment Utility
The solution was posted in Comment: ID:21837697
0
 
LVL 18

Expert Comment

by:Richard Lee
Comment Utility
The solution was posted in Comment: ID:21837697
0
 

Author Comment

by:jerute
Comment Utility
Sorry Da Tribe. Didn't read you comment fully. You get the points fairly.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now