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
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