Solved

I'm having difficulty understanding page inheritance

Posted on 2008-06-21
8
614 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

751 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