[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 678
  • Last Modified:

BasePage in APP_Code not being inherited properly

I have the following setup. I have a VB file in my App_Code folder that I want to act as a basepage for common behavior. I would like my my aspx.vb file to inherit this class but when I do this my aspx file calls asp:Content an unrecognized tag. What am I not doing or doing wrong?
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web
Imports DataAccess
Imports System.Configuration.ConfigurationManager
Imports Microsoft.VisualBasic

Namespace pageUtilities
    Public MustInherit Class BasePage
        Inherits System.Web.UI.Page

        Protected MustOverride ReadOnly Property pageName() As String
        Protected MustOverride Property contentControl() As Content

        Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
            loadPage()
        End Sub
        Protected Sub loadPage()
            Dim label As New Label

            'create error label
            label.ID = "lblErrorMessage"
            label.CssClass = "errorLabel"

            'add context to display page contents
            contentControl.Controls.Add(label)
            contentControl.Controls.Add(getTable(pageName))
        End Sub
    End Class



End Namespace

__________________________________________________________________

Class BEIndex
    Inherits pageUtilities.BasePage
    Protected Overrides ReadOnly Property pageName() As String
        Get
            Return "BEIndex.aspx"
        End Get
    End Property
    Protected Overrides Property contentControl() As Content
        Get
            Return cntMain
        End Get
        Set(ByVal value As Content)
            cntMain = value
        End Set
    End Property



End Class
__________________________________________________________________

<%@ Page  Language="VB" AutoEventWireup="false" CodeFile="BEIndex.aspx.vb" Inherits="BEIndex"%>
<asp:Content ID="cntMain" ContentPlaceHolderID="MainContent" Runat="Server"/>

Open in new window

0
rufassa
Asked:
rufassa
  • 2
1 Solution
 
Alfred A.Commented:
Hi,

The Inherits part of your page directive, there should be a project namespace in it.  

Inherits="NamespaceOfProject.BEIndex"

This might be the problem.
0
 
Alfred A.Commented:
Hi,

I did not noticed that you are using a web content form, you might have forgotten to put the MasterPageFile in the page directive.

<%@ Page  Language="VB" AutoEventWireup="false" MasterPageFile="~/Sample.Master"  CodeFile="BEIndex.aspx.vb" Inherits="BEIndex"%>
0
 
rufassaAuthor Commented:
That allowed the aspx file to use the asp:content but the aspx.VB file can not see it. At this part of the code:

        Get
            Return cntMain
        End Get
        Set(ByVal value As Content)
            cntMain = value
        End Set

The cntMain gets "Name 'cntMain' is not declared"
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now