Problems with derived web control

M

Martin Horst

Hi,

I've created a new Label web control which I derived from the
WebControls.Label
class. In the derived class I've replaced the Text function to return the
control text
from a resource file. This all works fine if I start the web application.
My problem is that these derived controls aren't displayed in the design
view of
the html designer. Instead the designer shows an error box for each control.
The error message comes from an InvalidCastException exception.

In the aspx file I added the following server tag:
<%@ Register TagPrefix="cnm" Namespace="cnm.library.web.ctrl"
Assembly="CNMLib2" %>

and all controls are create like this:
<cnm:Label id="lblTest" style="Z-INDEX: 101; LEFT: 20px; POSITION: absolute;
TOP: 22px" runat="server"></cnm:Label>


The code of the derived Label control:
[Designer(typeof(cnm.library.web.ctrl.Label))]
[ConstructorNeedsTagAttribute(false)]
public class Label : System.Web.UI.WebControls.Label
{
public override string Text
{
get
{
return XMLResource.Instance.Text[this];
}
set
{
base.Text = value;
}
}
}

Thanks in advance
Martin Horst
 

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,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top