Problems with derived web control

Discussion in 'ASP .Net Web Controls' started by Martin Horst, Jul 7, 2005.

  1. Martin Horst

    Martin Horst Guest

    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
     
    Martin Horst, Jul 7, 2005
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    440
    Alf P. Steinbach
    May 23, 2007
  2. Replies:
    1
    Views:
    425
    myork
    May 23, 2007
  3. Replies:
    1
    Views:
    413
    Victor Bazarov
    May 23, 2007
  4. David
    Replies:
    3
    Views:
    437
    Grizlyk
    Jan 29, 2008
  5. William French

    rendering derived control from composite control

    William French, Dec 2, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    234
    Wayne
    Dec 3, 2003
Loading...

Share This Page