Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The base class includes the field 'btnLogin', but its type (FoodOrder.App_Code.LinkButtonDefault) is not compatible

Tags:

c#

asp.net

The base class includes the field 'btnLogin', but its type (FoodOrder.App_Code.LinkButtonDefault) is not compatible with the type of control (FoodOrder.App_Code.LinkButtonDefault).

aspx:

<%@ Register Namespace="FoodOrder.App_Code" TagPrefix="ac1" %>
<ac1:LinkButtonDefault ID="btnLogin" runat="server" Text="Prijava" CssClass="gumbek" 
                onclick="btnLogin_Click" />

LinkButtonDefault:

namespace FoodOrder.App_Code
{
    public class LinkButtonDefault : LinkButton
    {
        protected override void OnLoad(System.EventArgs e)
        {
            Page.ClientScript.RegisterStartupScript(GetType(), "addClickFunctionScript",
                _addClickFunctionScript, true);

            string script = String.Format(_addClickScript, ClientID);
            Page.ClientScript.RegisterStartupScript(GetType(), "click_" + ClientID,
                script, true);
            base.OnLoad(e);
        }

        private const string _addClickScript = "addClickFunction('{0}');";

        private const string _addClickFunctionScript =
            @"  function addClickFunction(id) {{
            var b = document.getElementById(id);
            if (b && typeof(b.click) == 'undefined') b.click = function() {{
                var result = true; if (b.onclick) result = b.onclick();
                if (typeof(result) == 'undefined' || result) {{ eval(b.getAttribute('href')); }}
            }}}};";
    }
}

aspx.designer.cs:

protected global::FoodOrder.App_Code.LinkButtonDefault btnLogin;

Can someone explain me error?

like image 684
senzacionale Avatar asked Sep 18 '10 16:09

senzacionale


1 Answers

I think you have a circular reference occuring with the App_Code folder.

MS recommends two approaches to fix: http://support.microsoft.com/kb/919284

Either modify the web.config to set the <compilation> element to false (only recommended for small applications)

OR

Reorder the folders in your application. AKA - put your link button class somewhere else.

like image 146
Kevin LaBranche Avatar answered Oct 11 '22 16:10

Kevin LaBranche