base class field is not compatible with type of control

Last post 11-05-2008 12:05 PM by Will129. 3 replies.

Sort Posts:

  • base class field is not compatible with type of control

    09-13-2003, 3:50 AM
    • Member
      575 point Member
    • kuponutcom
    • Member since 11-01-2002, 10:31 AM
    • Posts 162
    Parser Error

    Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

    Parser Error Message: The base class includes the field 'dgPager', but its type (System.Web.UI.WebControls.DataGridPagerStyle) is not compatible with the type of control (ASP.DataGridPager_ascx).



    Line 92: <br>
    Line 93: <form id="Form1" method="post" runat="server">
    Line 94: <DataPagerDemo:DataGridPager id="dgPager" runat="server"></DataPagerDemo:DataGridPager>
    Line 95: <asp:datagrid id="DG" runat="server" HorizontalAlign="Center" width="95%" PageSize="50" AllowPaging="True"
    Line 96: PagerStyle-Visible="false">



    in the aspx.cs file

    protected System.Web.UI.WebControls.DataGrid DG;
    protected System.Web.UI.WebControls.DataGridPagerStyle dgPager;

    and in its respective .aspx: (where line 94 is erroring..)

    <%@ Page Language="c#" CodeBehind="PS2.aspx.cs" AutoEventWireup="false" Inherits="HybridCSVS.SPSearchResultsDataGrid" %>
    <%@ Register tagprefix="DataPagerDemo" Tagname="DataGridPager" Src="DataGridPager.ascx" %>





    ANY insight on the reason this error is occuring??
  • Re: base class field is not compatible with type of control

    09-13-2003, 11:26 AM
    • Participant
      1,057 point Participant
    • Ryan Milligan
    • Member since 06-11-2002, 12:55 PM
    • Posts 210
    When you put a control in an ASPX file, a corresponding field whose name is the same as the control's ID is automatically created in the generated class. So the generated class has two fields with the same name and different types, which is illegal. You need to change the name either of the control, or of the DataGridPagerStyle.

    -- Ryan Milligan
  • Re: base class field is not compatible with type of control

    02-19-2008, 10:08 PM
    • Member
      2 point Member
    • dotnetpost
    • Member since 02-20-2008, 3:06 AM
    • Posts 1

    I had similar issue.  The issue fixed by changing 'CodeFile' tag to 'CodeBehind' tag in the ascx file.  I guess this affects how .net compiles the app and hence was throwing error.

  • Re: base class field is not compatible with type of control

    11-05-2008, 12:05 PM
    • Member
      2 point Member
    • Will129
    • Member since 11-05-2008, 11:55 AM
    • Posts 1

    I had the same message with a user control inheriting from a generic class.

    The base class includes the field 'uxContactDetailsView', but its type (ClassName`1[[Namespace.GenericType, AssemblyNamePrefix.AssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]) is not compatible with the type of control (ASP.contactdetailsview_ascx)

     The "ClassName`1[[blahblahblah, blah, blah, blah]]" is how to declare the generic type in the Inherits attribute of the <%Control Language = "C#" ... > tag - apparently it doesn't understand the C# "ClassName<MyGenericType>" syntax, and needs to use the CLR syntax ("ClassName`1[[MyGenericType]]")

    Turns out the user control wasn't in a namespace (so it assumed I wanted to use "ASP" as the namespace?) - and giving this class file a namespace solved the problem.

     So the user control .ascx file now starts with <% Control Language = "C#" Inherits = "MyNamespace.MyType`1[[MyGenericNameSpace.MyGenericType, MyDll, Version=1.0.0.0., Culture=null, PublicKeyToken=null]]" CodeBehind = "MyCodeFile.ascx.cs" %>

Page 1 of 1 (4 items)