473,809 Members | 2,724 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inheritance Problem (src vs. Codebehind)

Hello,

I'm trying to implement sample I found on page templates, so I do not have
to maintain "<html><head>.. ." on all my documents. But don't let that
confuse you, this is an inheritance problem.

Basically, I'm using VS.NET IDE for development, If I use the src="..." tag
in the @Page directive it works, but if I use codebehind="... ", I get a
runtime error that it cannot find my first class I'm inheriting. It's
almost like the assembly dll it is compiling doesn't contain the namespace
I've defined (But I have rebuilt it, even checked the timestamp to make sure
it is being updated)

The error I get from the browser when requesting default.aspx is as follows:
Parser Error Message: Could not load type 'aspdotnet.Page TemplateSetup'.
(and it highlights my @page directive line)

I originally had a C# example and changed it down to VB.NET, so I'm sure I'm
missing something simple.

Here is my source files, if it helps.

default.aspx
*************** **
<%@ Page Language="vb" AutoEventWireup ="false" Codebehind="def ault.aspx.vb"
Inherits="aspdo tnet.PageTempla teSetup" %>

<form id="testform" runat="server">
<h3>Testing Templates</h3>
</form>

default.aspx.vb
*************** ****
Imports System

Namespace aspdotnet

Public Class PageTemplateSet up
Inherits aspdotnet.PageT emplateBase

Sub PageTemplateSet up()
PageTitle = "My Page Title"
End Sub
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub

'NOTE: The following placeholder declaration is required by the Web
Form Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

End Class

End Namespace

PageTemplateBas e.vb
*************** *******
Imports System

Namespace aspdotnet

Public Class PageTemplateBas e
Inherits aspdotnet.PageB ase

Protected Overrides Sub Render(ByVal writer As
System.Web.UI.H tmlTextWriter)
'First we will build up the html document, the head section
'and the body section.
writer.Write("< html><head><tit le>" & PageTitle &
"</title></head><body>")

'The base class will render the controls from the
'derived .ASPX file.
MyBase.Render(w riter)

writer.Write("</body></html>")
End Sub
End Class
End Namespace

PageBase.vb
*************** ***
Imports System

Namespace aspdotnet

Public Class PageBase
Inherits System.Web.UI.P age

Private _pageTitle As String

Public Property PageTitle() As String
Get
Return _pageTitle
End Get
Set(ByVal Value As String)
_pageTitle = Value
End Set
End Property

End Class

End Namespace

**********

Thank you for any help you can give!
--Michael
Nov 18 '05 #1
1 1516
I figured out my problem, in the default.aspx.vb file I had to take the
class I use there out of the aspdotnet namespace. Now why that worked I do
not know...

"Michael" <raterus@localh ost> wrote in message
news:el******** ******@tk2msftn gp13.phx.gbl...
Hello,

I'm trying to implement sample I found on page templates, so I do not have
to maintain "<html><head>.. ." on all my documents. But don't let that
confuse you, this is an inheritance problem.

Basically, I'm using VS.NET IDE for development, If I use the src="..." tag in the @Page directive it works, but if I use codebehind="... ", I get a
runtime error that it cannot find my first class I'm inheriting. It's
almost like the assembly dll it is compiling doesn't contain the namespace
I've defined (But I have rebuilt it, even checked the timestamp to make sure it is being updated)

The error I get from the browser when requesting default.aspx is as follows: Parser Error Message: Could not load type 'aspdotnet.Page TemplateSetup'.
(and it highlights my @page directive line)

I originally had a C# example and changed it down to VB.NET, so I'm sure I'm missing something simple.

Here is my source files, if it helps.

default.aspx
*************** **
<%@ Page Language="vb" AutoEventWireup ="false" Codebehind="def ault.aspx.vb" Inherits="aspdo tnet.PageTempla teSetup" %>

<form id="testform" runat="server">
<h3>Testing Templates</h3>
</form>

default.aspx.vb
*************** ****
Imports System

Namespace aspdotnet

Public Class PageTemplateSet up
Inherits aspdotnet.PageT emplateBase

Sub PageTemplateSet up()
PageTitle = "My Page Title"
End Sub
#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()

End Sub

'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor.
InitializeCompo nent()
End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub

End Class

End Namespace

PageTemplateBas e.vb
*************** *******
Imports System

Namespace aspdotnet

Public Class PageTemplateBas e
Inherits aspdotnet.PageB ase

Protected Overrides Sub Render(ByVal writer As
System.Web.UI.H tmlTextWriter)
'First we will build up the html document, the head section
'and the body section.
writer.Write("< html><head><tit le>" & PageTitle &
"</title></head><body>")

'The base class will render the controls from the
'derived .ASPX file.
MyBase.Render(w riter)

writer.Write("</body></html>")
End Sub
End Class
End Namespace

PageBase.vb
*************** ***
Imports System

Namespace aspdotnet

Public Class PageBase
Inherits System.Web.UI.P age

Private _pageTitle As String

Public Property PageTitle() As String
Get
Return _pageTitle
End Get
Set(ByVal Value As String)
_pageTitle = Value
End Set
End Property

End Class

End Namespace

**********

Thank you for any help you can give!
--Michael

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4383
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two files containing some templates: adjacency_list.hpp and mem_fn.hpp can not compile. Does anyone have any solutions?
8
1514
by: Krunom Ancini | last post by:
Hi, im just the beginner and im using c#-codebehind in my asp.net-application.... What should i do to make my application work "without" code-behind (without dll.-s in bin-folder)? I was googling something about Src instead of Codebehind (in @page directive) but i dont know where to start...
2
2652
by: varun_789 | last post by:
hello friend, while developing an application, i encountered a subtle point. for a aspx page, what is the difference between src property and codebehind property ? src stands for code-behind class to compile where as
0
2289
by: Dave | last post by:
Hi, I understand that the CodeBehind= is designed to be used by VS and not actually part of the .NET framework However, in my BenefitsVB project to test how the SRC works, I created a simple aspx and codebind (below) and added Src="WebFormSrc.aspx.vb" to the page directive. I then tried to browse the page and got:
6
1789
by: Nehal Shah | last post by:
I've read that in the Page Directive of an aspx page, changing the CodeBehind attribute to Src saves you from having to compile the page before refreshing. This is preferable in a large development environment where rather than having each developer running a local copy of a website, they can make changes simultaneously to a central web server without stepping on each other's toes as far as compilation is concerned. ANYWAY, this is fine...
12
1760
by: A.M | last post by:
Hi, Using VS.NET 2003, If i use SRC page attribute instead of CodeBehind, do i still have intelisence and generally IDE support for that? Thanks, Ali
5
2051
by: Invalidlastname | last post by:
Hi, I just read the pattern "Design and Implementation Guidelines for Web Clients" from MSDN. Here is my question. In chapter 3, http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/diforwc-ch03.asp , the article mentions using page inheritance to maintain common page layout. We currently use page inheritance approach to segment the function areas. In each function area, there is a base page to provide the common...
1
1503
by: Martin Eyles | last post by:
I am trying to put web controls in my page which inherit their position from style property. So far I have the following code, but the "hello"s don't appear in their desired position. Has anyone any idea how to fix this? Thanks, ME TestPositionInheritance.aspx -----------------------------------
7
2222
by: Jack | last post by:
Hello, What is the difference between SRC and CODEBEHIND Tags? Example <%@ Page Language="vb" ValidateRequest="false" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" %> or
0
10635
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10378
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7653
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3013
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.