Solved

I'm having difficulty understanding page inheritance

Posted on 2008-06-21
8
613 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

762 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