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,132 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
[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
1 Comment
 
LVL 14

Accepted Solution

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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

740 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