Solved

I'm having difficulty understanding page inheritance

Posted on 2008-06-21
8
611 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
ID: 21837697
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
ID: 21837745
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
ID: 21839652
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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:jerute
ID: 21840332
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
ID: 21842376
The solution was posted in Comment: ID:21837697
0
 
LVL 18

Expert Comment

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

Author Comment

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

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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 was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

803 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