is not allowed here because it does not extend class 'System.Web.UI.UserControl'

10,887

This Control might not be in the current namespace.

read this : http://forums.asp.net/t/1557864.aspx?UserControl+is+not+allowed+here+because+it+does+not+extend+class+System+Web+UI+UserControl+

Hope will help.

Share:
10,887
Isaac Levin
Author by

Isaac Levin

.Net Developer by trade, but usually jump into random other environments as needed.

Updated on October 20, 2022

Comments

  • Isaac Levin
    Isaac Levin over 1 year

    I have created a User Control that extends the DEVExpress ASPxGridView. My goal is to have this control be a template (style settings, shared properties) for all the times I would but the GridView somewhere, but instead of having to add the properties and Styles, I could use it as a template. All other properties, events, etc would be inherited from the base class

    Here is my ascx.cs code

    namespace CORE.Web.UserControls
    {
       public partial class ucGridView : DevExpress.Web.ASPxGridView.ASPxGridView
          {
          }
    }
    

    and the ascx code

    <dx:ASPxGridView ID="gcGridView" runat="server" AutoGenerateColumns="False" Styles-AlternatingRow-Enabled="True">
    <Settings HorizontalScrollBarMode="auto" VerticalScrollBarMode="auto" VerticalScrollableHeight="500" />
    <SettingsPager PageSize="20">
        <PageSizeItemSettings Visible="true" ShowAllItem="true" />
    </SettingsPager>
    <SettingsBehavior AllowFocusedRow="true" />
    <Styles>
        <Header VerticalAlign="Top" Wrap="True"></Header>
        <AlternatingRow Enabled="True"></AlternatingRow>
    </Styles>
    

    and where it is put in the aspx page

    <uc1:ucGridView runat="server" ID="ucGridView" DataSourceID="masterStatsObjectDataSource" />
    

    There are other issues, like columns and whatever that know I will deal with, but I am hitting a roadblock just getting it to work at runtime

    I get this error message

    'CORE.Web.UserControls.ucGridView' is not allowed here because it does not extend class 'System.Web.UI.UserControl'.

    Line 1 of the aspx page is

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucGridView.ascx.cs" Inherits="CORE.Web.UserControls.ucGridView" %>

    I am not sure where to go from here, as this should be easy. Any help would be greatly appreciated.

    Thanks

  • RacerNerd
    RacerNerd almost 10 years
    Can you explain this a little more? I have the same issue and am not sure what to do. Can you give an example of the correct code so I can see how it differs from the original code in your post?
  • Matt
    Matt about 9 years
    That helped in my case. Strangely, the error did only occur when I tried to "publish precompiled." After fixing the namespace issue (it was wrong in the website registration, not in the C# part), everything compiled succsssfully.