Parser Error

L

Lubomir

Hi,

I have a custom control, defined in the file LinkLabel.cs, compiled into
assembly MyControl.dll

namespace MyControl
{
[DefaultProperty("Text"), ToolboxData("<{0}:LinkLabel
runat=server></{0}:LinkLabel>")]
public class LinkLabel : Label
{
…..
}
.....
}
The control’s dll is in a bin directory of the web page, which will use it.

In my “asp†page I registered control:
<%@ Register TagPrefix="mspo" Namespace="MyControl" Assembly="MyControl" %>

and used the control:
<mspo:LinkLabel id="LinkLabel1" runat="server" ></mspo:LinkLabel>

In code behind:
protected MyControl.LinkLabel LinkLabel1;
…..
LinkLabel1.Text = "blablabla";

I can compile my web page with no error, however, when I run it, I get a
parser error:

Parser Error Message: The base class includes the field 'LinkLabel1', but
its type (MyControl.LinkLabel) is not compatible with the type of control
(MyControl.LinkLabel).

Source error line:
<mspo:LinkLabel id="LinkLabel1" runat="server" ></mspo:LinkLabel>

Please note, that the types mentioned in Parser Error Message are identical.
When I change the definition of a control object in codebehind class
from
protected MyControl.LinkLabel LinkLabel1;

To
protected Label LinkLabel1; // Label is the base class for LinkLabel

everything is good.

What is wrong with the parser when I use inherited, LinkLabel class?

Thanks for a help.

Lubomir
 
R

Rowland Shaw

Lubomir said:
I have a custom control, defined in the file LinkLabel.cs, compiled into
assembly MyControl.dll

The control’s dll is in a bin directory of the web page, which will use it.

I can compile my web page with no error, however, when I run it, I get a
parser error:

Parser Error Message: The base class includes the field 'LinkLabel1', but
its type (MyControl.LinkLabel) is not compatible with the type of control
(MyControl.LinkLabel).

Please note, that the types mentioned in Parser Error Message are identical.

Are you referencing the same assembly at compile time to that being used at
runtime?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top