Solved

class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class

Posted on 2008-10-23
1
1,113 Views
Last Modified: 2013-12-17
This code worked in VS 2003, now I am moving much of this to VS 2008 and now I get the 'Make sure that the code defined in this code file matches the 'inherits' attribute, and that it extends the correct base class' error.

I have UserControl.cs in the App_Code\_Application\_Web\_UI\ directory (listing #1 below)

Then I have a user control in ~\UserControls\PageHeader.ascx that is getting the error (listing #2 below)

How do I fix the error (simple explanation if possible).
Thanks
JC

Listing #1
using System;
using System.Web;

namespace Cenet._Application.Web.UI
{
    //==============================================================================
    /// <remarks>
    /// Inherits and extends System.Web.UI.UserControl
    /// </remarks>
    //==============================================================================
    public class UserControl : System.Web.UI.UserControl
    {
        #region Overrides
        //==============================================================================
        /// <summary>
        /// Gets a reference to the Page instance that contains the user control.
        /// </summary>
        //==============================================================================\
        public new _Application.Web.UI.Page Page
        {
            get { return (_Application.Web.UI.Page)base.Page; }
        }
        #endregion
    }
}


Listing #2
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PageHeader.ascx.cs" Inherits="_UserControls_PageHeader" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

<table cellSpacing="0" cellPadding="0" width="100%" align="center" border="0" style=" vertical-align: top;">
      <TR style="height:48px;">
            <TD width="793" style="WIDTH: 793px; HEIGHT: 48px; vertical-align:top;"><img src="../../../../Images/InternalLogo.jpg" width="300" height="60" /></TD>
  <TD noWrap align="right" style="HEIGHT: 48px; vertical-align:top;">
                  <P><B><asp:Label id="lblCompanyDisplayName" Runat="server" EnableViewState="False"></asp:Label></B>&nbsp;</P>
                  <P><B><asp:label ID="lblDevWeb" Runat="server" EnableViewState="False" Font-Bold="True" ForeColor="Red"></asp:label></B>&nbsp;
                        <asp:label id="lblDay" runat="server" EnableViewState="False">Day</asp:label>&nbsp;
                        <asp:label id="lblDate" runat="server" EnableViewState="False">Date</asp:label>&nbsp;&nbsp;</P>
            </TD>
      </TR>
      <TR>
            <TD class="helpBar" width="793" style="WIDTH: 793px" colspan="2">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>            
            <telerik:RadMenu ID="RadMenu1" Runat="server" Skin="Default" Width="100%"
                DefaultGroupSettings-Flow="Horizontal">
<DefaultGroupSettings Flow="Horizontal"></DefaultGroupSettings>

<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

            </telerik:RadMenu>

        </TD>
      
      </TR>

</table>

using System;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using Cenet._Application;
using Telerik.Web.UI;

namespace Cenet._Application.Web.UI.UserControls
{
    //===================================================================================
    /// <remarks>
    ///      Common page header
    /// </remarks>
    //===================================================================================
    public abstract  class PageHeader : Cenet._Application.Web.UI.UserControl
    {
        // private variables
        private string _filler = string.Empty;
        private double _fillerHeight;
        private double _fillerWidth;
        private int _helpWindowWidth;
        private int _helpWindowHeight;
        private string _printerFriendlyLink = string.Empty;
        private ArrayList _scriptFiles = new ArrayList();
        private ArrayList _relatedLinks = new ArrayList();

        #region Web Form Designer generated code

        //=============================================================================================
        /// <summary>
        /// OnInit
        /// </summary>
        /// <param name="e"></param>
        //=============================================================================================
        protected override void OnInit(EventArgs e)
        {
            InitializeComponent();
            base.OnInit(e);
        }

        //=============================================================================================

        private void InitializeComponent()
        {
            //this.PreRender += new System.EventHandler(this.Page_PreRender);

        }


        #endregion

        #region Properties

        //===================================================================================
        /// <summary>
        /// Sets the filler image filename
        /// </summary>
        //===================================================================================
        public string FillerImage
        {
            set { _filler = value == null ? string.Empty : value; }
        }

        //===================================================================================
        /// <summary>
        /// Sets the height attribute of the filler image filename
        /// </summary>
        //===================================================================================
        public double FillerImageHeight
        {
            set { _fillerHeight = value; }
        }

        //===================================================================================
        /// <summary>
        /// Sets the width attribute of the filler image filename
        /// </summary>
        //===================================================================================
        public double FillerImageWidth
        {
            set { _fillerWidth = value; }
        }

        //===================================================================================
        /// <summary>
        /// Sets the height attribute of the help window
        /// </summary>
        //===================================================================================
        public int HelpWindowHeight
        {
            set { _helpWindowHeight = value; }
        }

        //===================================================================================
        /// <summary>
        /// Sets the width attribute of the help window
        /// </summary>
        //===================================================================================
        public int HelpWindowWidth
        {
            set { _helpWindowWidth = value; }
        }

        //===================================================================================
        /// <summary>
        /// Sets the link to a printer friendly page
        /// </summary>
        //===================================================================================
        public string PrinterFriendlyLink
        {
            set { _printerFriendlyLink = value == null ? string.Empty : value; }
        }


        #endregion
        #region Base Methods
        //===================================================================================
        /// <summary>
        /// Page Load event
        /// </summary>
        /// <param name="sender">Object that raised the event</param>
        /// <param name="e">Event arguments</param>
        //===================================================================================
        private void Page_Load(object sender, System.EventArgs e)
        {
            _helpWindowHeight = 450;
            _helpWindowWidth = 545;
            if (!IsPostBack)
            {
                //RadMenu1.Items.Insert(0, new RadMenuItem("item 1"));
                //RadMenu1.Items.Insert(1, new RadMenuItem("item 2"));
                //RadMenuItem item3 = new RadMenuItem("item 3");
                //item3.Items.Add(new RadMenuItem("item 3 1"));
                //item3.Items.Add(new RadMenuItem("Item 3 2"));
                //RadMenu1.Items.Insert(2, item3);
            }

        }

        //==============================================================
        /// <summary>
        /// Page PreRender event
        /// </summary>
        /// <param name="sender">Object that raised the event</param>
        /// <param name="e">Event arguments</param>
        //==============================================================
        private void Page_PreRender(object sender, System.EventArgs e)
        {
            const string SCRIPT_HTML = "<script language=\"javascript\" src=\"{0}\"></script>";
            string TestPath = string.Empty;
            int strLoc;
            Uri MyUrl = Request.Url;

            // Register script files
            foreach (string scriptFile in _scriptFiles)
            {
                this.Controls.Add(new LiteralControl(string.Format(SCRIPT_HTML, this.Page.BaseLinkURL(scriptFile))));
            }

            // Set 1st row variables
            lblDay.Text = DateTime.Today.DayOfWeek.ToString("G");
            lblDate.Text = DateTime.Today.ToString("MMMM d, yyyy");

            RadMenu1.Items.Clear();

            if (Session.Count > 0)
            {

                //Determine if code is running on testserver or localhost...
                TestPath = MyUrl.AbsoluteUri.ToString();
                TestPath = TestPath.ToLower();
                strLoc = TestPath.IndexOf("test.cenet.us/");
                //on devweb...
                if (strLoc != -1)
                {
                    lblDevWeb.Text = "DEVELOPMENT";
                }
                else
                {
                    strLoc = TestPath.IndexOf("localhost/");
                    if (strLoc != -1)
                    {
                        //on localhost
                        lblDevWeb.Text = "DEVELOPMENT";
                    }
                    else
                    {
                        lblDevWeb.Text = "";
                    }
                }
            }
            if (Session.Count > 0)
            {
                AddTopNav("Home", "~/_Home/Default.aspx");
                //Add additional links -  based on security
                if (Security.CheckUserAccess(Constants.MODULE_WORK_TRAVEL) == true)
                    AddTopNav("Work and Travel", "~/_WorkAndTravel/Default.aspx");
                if (Security.CheckUserAccess(Constants.MODULE_TRAINEE_INTERN) == true)
                    AddTopNav("Trainee/Intern", "~/_TraineeAndIntern/Default.aspx");
                if (Security.CheckUserAccess(Constants.MODULE_PLACEMENT) == true)
                    AddTopNav("Placement", "~/_Placement/Default.aspx");
                if (Security.CheckUserAccess(Constants.MODULE_MANAGER) == true)
                    AddTopNav("Manager", "~/_Manager/Default.aspx");


                //lkbSignOut.Visible = true;

                // If help link is available
                //if (this.Page.HelpFile.Length > 0)
                //{
                //    lnkHelp.NavigateUrl = "javascript:openHelpWindow('" + this.Page.BaseLinkURL(this.Page.HelpFile) + "'," +
                //        _helpWindowWidth.ToString() + "," + _helpWindowHeight.ToString() + ");";
                //    lnkHelp.Visible = true;
                //}

                AddTopNav("Logout", "~/_Home/Default.aspx");
            }
        }
        #endregion

        //==============================================================
        /// <summary>
        /// Adds a script to be registered with the page
        /// </summary>
        /// <param name="script">script file name</param>
        //==============================================================
        public void RegisterScriptFile(string script)
        {
            _scriptFiles.Add(script);
        }

        //==============================================================
        /// <summary>
        /// Adds a related link
        /// </summary>
        /// <param name="item"></param>
        //==============================================================
        public void AddRelatedLink(RelatedLink item)
        {
            _relatedLinks.Add(item);
        }


        //===================================================================================
        /// <summary>
        /// AddMenuHeader
        /// </summary>
        //===================================================================================
        public void AddTopNav(string menuText, string menuURL)
        {
            RadMenuItem newItem = new RadMenuItem();
            newItem.Text = menuText;
            newItem.NavigateUrl = menuURL;
            RadMenu1.Items.Add(newItem);

        }


        //============================================================================
        //== lkbSignOut_Click - sign in to the application...
        //============================================================================
        private void lkbSignOut_click(object sender, System.EventArgs e)
        {
            Session.Abandon();
            Response.Redirect("~/SignIn.aspx");
        }
    }

    //==============================================================
    /// <remarks>
    /// Represents s related link
    /// </remarks>
    //==============================================================
    public sealed class RelatedLink
    {
        private string _name = string.Empty;
        private string _link = string.Empty;

        #region Properties
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }
        public string Link
        {
            get { return _link; }
            set { _link = value; }
        }
        #endregion

        #region Constructors/Destructor
        //==============================================================
        /// <summary>
        /// Constructor
        /// </summary>
        //==============================================================
        public RelatedLink()
            : this(string.Empty, string.Empty)
        { }
        public RelatedLink(string name, string link)
            : base()
        {
            this.Name = name;
            this.Link = link;
        }
        #endregion
    }
}
0
Comment
Question by:cenetadmin
1 Comment
 
LVL 14

Accepted Solution

by:
Ramuncikas earned 500 total points
Comment Utility
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PageHeader.ascx.cs" Inherits="Cenet._Application.Web.UI.UserControls.PageHeader" %>
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

743 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now