English 中文(简体)
基地类别包括外地,但与控制类型不符的类型
原标题:Base class includes field but type not compatible with type of control

基地类别包括实地镜头,但其类型(网站.App_Code.CustomLabelControl)与控制类型(网站.App_Code.CustomLabelControl)不一致。

我以同样的方式做了许多海关控制,但今天我发现这一错误。

I have a web application project with the below class in App_Code directory a tagprefix reference in web.config for the control in class.

www.un.org/Depts/DGACM/index_spanish.htm 现在我做了些什么?

Web.Config

<system.web>
    <pages>
        <controls>
            <add namespace="web.App_Code" tagPrefix="CControls"/>...

Markup

<form id="form1" runat="server">
<div>
    <CControls:CustomLabelControl runat="server" OnClickText="Welcome" ID="lbl">
    </CControls:CustomLabelControl>
</div>
</form>

Class File

namespace web.App_Code
{
    public class CustomLabelControl : Control, IPostBackEventHandler, IPostBackDataHandler
    {
        private string _onClickText;

        public CustomLabelControl()
        {

        }

        public string OnClickText
        {
            get { return _onClickText; }
            set { _onClickText = value; }
        }

        public void RaisePostBackEvent(string eventArgument)
        {
            throw new System.NotImplementedException();
        }


        public bool LoadPostData(string postDataKey, NameValueCollection postCollection)
        {
            throw new System.NotImplementedException();
        }


        public void RaisePostDataChangedEvent()
        {
            throw new System.NotImplementedException();
        }
    }
}

I ve checked these resources already:

最佳回答

Try specifying the assembly name too:

<add tagPrefix="CControls" namespace="web.App_Code" assembly="web.App_Code" />

为了明确起见,我将考虑为您的海关管制建立一个专门的名称空间。 可能的话,例如web.App_Code.CustomControls:

<add tagPrefix="CControls" namespace="web.App_Code.CustomControls" assembly="web.App_Code.CustomControls" />
问题回答

参考网络中的化轴用户控制。 a. 混淆不成一页:

<add tagPrefix="proj1" src="~/userControls/Invoiceshow.ascx" tagName="proj1tagname">

这解决了我的问题。

我知道这一点是老的,但我有同样的错误,试图将文字箱改为标签控制。 我简单地将控制权从“Insulin”改为“Insulin2”,从而确定了这一问题。 我不敢肯定为什么会奏效,但这可能是微软的问题。

在审查了更多情况后,我注意到,如果我关闭了第一页的表格,正在视力演播室工作,然后重新开放,那么这一错误就完全消失了? 我希望这一点有助于一些人。

Encountered this problem while converting a Web Forms website to MVC Web App, and changing target framework to 4.6. The solution for me was to set the controlRenderingCompatibilityVersion attribute on the pages element in web.config:

<system.web>
   <pages validateRequest="true" controlRenderingCompatibilityVersion="4.6" clientIDMode="AutoID">
</system.web>

In my case, my application was published one , it was working in my local as well as in UAT environment .The problem was only in production. so the mistake what i did was, i not moved the new published version ascx files to production, similarly it was reading old version published file. By moving the latest files to production or replacing them, this issue got resolved.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签