Composite control - sub control as a property not rendering

Discussion in 'ASP .Net Web Controls' started by Bob Jones, Apr 6, 2007.

  1. Bob Jones

    Bob Jones Guest

    I can't get the text property of this label control I am exposing to
    update in the designer (when I cange the label's text property) or
    when rendered on a web page. However, if I cange the font property of
    the label control it updates everthing! I know I am doing something
    stupid-wrong. Anyone help?


    public class SDNetLabelTextBox : ContainerBase,
    ICompositeControlDesignerAccessor, ISDNetControl
    {
    private Label _label;


    public SDNetLabelTextBox()
    {
    this._label = new Label();
    this._label.ID += "_SDLabel";
    this._label.Text = "SDNet LabelTextBox";
    }


    public override void RenderControl(HtmlTextWriter writer)
    {
    this._label.RenderControl(writer);
    base.RenderControl(writer);
    }


    public Label Label
    {
    get { return this._label; }
    set { this._label = value; }
    }

    #region ICompositeControlDesignerAccessor Members

    void ICompositeControlDesignerAccessor.RecreateChildControls()
    {
    base.ChildControlsCreated = false;
    EnsureChildControls();
    }

    #endregion
    Bob Jones, Apr 6, 2007
    #1
    1. Advertising

  2. Bob Jones

    Bob Jones Guest

    On Apr 6, 11:49 am, "Bob Jones" <> wrote:
    > I can't get the text property of this label control I am exposing to
    > update in the designer (when I cange the label's text property) or
    > when rendered on a web page. However, if I cange the font property of
    > the label control it updates everthing! I know I am doing something
    > stupid-wrong. Anyone help?
    >
    > public class SDNetLabelTextBox : ContainerBase,
    > ICompositeControlDesignerAccessor, ISDNetControl
    > {
    > private Label _label;
    >
    > public SDNetLabelTextBox()
    > {
    > this._label = new Label();
    > this._label.ID += "_SDLabel";
    > this._label.Text = "SDNet LabelTextBox";
    > }
    >
    > public override void RenderControl(HtmlTextWriter writer)
    > {
    > this._label.RenderControl(writer);
    > base.RenderControl(writer);
    > }
    >
    > public Label Label
    > {
    > get { return this._label; }
    > set { this._label = value; }
    > }
    >
    > #region ICompositeControlDesignerAccessor Members
    >
    > void ICompositeControlDesignerAccessor.RecreateChildControls()
    > {
    > base.ChildControlsCreated = false;
    > EnsureChildControls();
    > }
    >
    > #endregion


    So, nobody has any idea why this doesn't work?
    Bob Jones, Apr 9, 2007
    #2
    1. Advertising

  3. Bob Jones

    Bob Jones Guest

    On Apr 8, 11:32 pm, "Bob Jones" <> wrote:
    > On Apr 6, 11:49 am, "Bob Jones" <> wrote:
    >
    >
    >
    >
    >
    > > I can't get the text property of this label control I am exposing to
    > > update in the designer (when I cange the label's text property) or
    > > when rendered on a web page. However, if I cange the font property of
    > > the label control it updates everthing! I know I am doing something
    > > stupid-wrong. Anyone help?

    >
    > > public class SDNetLabelTextBox : ContainerBase,
    > > ICompositeControlDesignerAccessor, ISDNetControl
    > > {
    > > private Label _label;

    >
    > > public SDNetLabelTextBox()
    > > {
    > > this._label = new Label();
    > > this._label.ID += "_SDLabel";
    > > this._label.Text = "SDNet LabelTextBox";
    > > }

    >
    > > public override void RenderControl(HtmlTextWriter writer)
    > > {
    > > this._label.RenderControl(writer);
    > > base.RenderControl(writer);
    > > }

    >
    > > public Label Label
    > > {
    > > get { return this._label; }
    > > set { this._label = value; }
    > > }

    >
    > > #region ICompositeControlDesignerAccessor Members

    >
    > > void ICompositeControlDesignerAccessor.RecreateChildControls()
    > > {
    > > base.ChildControlsCreated = false;
    > > EnsureChildControls();
    > > }

    >
    > > #endregion

    >
    > So, nobody has any idea why this doesn't work?- Hide quoted text -
    >
    > - Show quoted text -


    Ok.. here is what I have found to work so far...

    If I create a custom control and derive it from a base web control and
    then add the [NotifyParentProperty(true)] attribute to the overriden
    property I want to update in the designer (e.g. Text property of the
    label) and use my custom control instead of the standard control.
    Everything updates for the property.

    public class SDNetLabel : Label
    {
    [NotifyParentProperty(true)]
    public override string Text
    {
    get
    {
    return base.Text;
    }
    set
    {
    base.Text = value;
    }
    }

    [NotifyParentProperty(true)]
    public override System.Drawing.Color ForeColor
    {
    get
    {
    return base.ForeColor;
    }
    set
    {
    base.ForeColor = value;
    }
    }
    }

    Is there a property or attribute that can be specified on the web
    controls to make them always update the parent when a property changes
    or am I stuck writing derived controls just to set an attribute on the
    properties I want updated via the designer?

    Bob
    Bob Jones, Apr 9, 2007
    #3
  4. Bob Jones

    Bob Jones Guest

    FOR MICROSOFT: Composite control - sub control as a property not rendering

    On Apr 9, 12:22 pm, "Bob Jones" <> wrote:
    > On Apr 8, 11:32 pm, "Bob Jones" <> wrote:
    >
    >
    >
    >
    >
    > > On Apr 6, 11:49 am, "Bob Jones" <> wrote:

    >
    > > > I can't get the text property of this label control I am exposing to
    > > > update in the designer (when I cange the label's text property) or
    > > > when rendered on a web page. However, if I cange the font property of
    > > > the label control it updates everthing! I know I am doing something
    > > > stupid-wrong. Anyone help?

    >
    > > > public class SDNetLabelTextBox : ContainerBase,
    > > > ICompositeControlDesignerAccessor, ISDNetControl
    > > > {
    > > > private Label _label;

    >
    > > > public SDNetLabelTextBox()
    > > > {
    > > > this._label = new Label();
    > > > this._label.ID += "_SDLabel";
    > > > this._label.Text = "SDNet LabelTextBox";
    > > > }

    >
    > > > public override void RenderControl(HtmlTextWriter writer)
    > > > {
    > > > this._label.RenderControl(writer);
    > > > base.RenderControl(writer);
    > > > }

    >
    > > > public Label Label
    > > > {
    > > > get { return this._label; }
    > > > set { this._label = value; }
    > > > }

    >
    > > > #region ICompositeControlDesignerAccessor Members

    >
    > > > void ICompositeControlDesignerAccessor.RecreateChildControls()
    > > > {
    > > > base.ChildControlsCreated = false;
    > > > EnsureChildControls();
    > > > }

    >
    > > > #endregion

    >
    > > So, nobody has any idea why this doesn't work?- Hide quoted text -

    >
    > > - Show quoted text -

    >
    > Ok.. here is what I have found to work so far...
    >
    > If I create a custom control and derive it from a base web control and
    > then add the [NotifyParentProperty(true)] attribute to the overriden
    > property I want to update in the designer (e.g. Text property of the
    > label) and use my custom control instead of the standard control.
    > Everything updates for the property.
    >
    > public class SDNetLabel : Label
    > {
    > [NotifyParentProperty(true)]
    > public override string Text
    > {
    > get
    > {
    > return base.Text;
    > }
    > set
    > {
    > base.Text = value;
    > }
    > }
    >
    > [NotifyParentProperty(true)]
    > public override System.Drawing.Color ForeColor
    > {
    > get
    > {
    > return base.ForeColor;
    > }
    > set
    > {
    > base.ForeColor = value;
    > }
    > }
    >
    > }
    >
    > Is there a property or attribute that can be specified on the web
    > controls to make them always update the parent when a property changes
    > or am I stuck writing derived controls just to set an attribute on the
    > properties I want updated via the designer?
    >
    > Bob- Hide quoted text -
    >
    > - Show quoted text -
    Bob Jones, Apr 9, 2007
    #4
  5. Bob Jones

    Bob Jones Guest

    Re: FOR MICROSOFT: Composite control - sub control as a property not rendering

    On Apr 9, 2:41 pm, "Bob Jones" <> wrote:
    > On Apr 9, 12:22 pm, "Bob Jones" <> wrote:
    >
    >
    >
    > > On Apr 8, 11:32 pm, "Bob Jones" <> wrote:

    >
    > > > On Apr 6, 11:49 am, "Bob Jones" <> wrote:

    >
    > > > > I can't get the text property of this label control I am exposing to
    > > > > update in the designer (when I cange the label's text property) or
    > > > > when rendered on a web page. However, if I cange the font property of
    > > > > the label control it updates everthing! I know I am doing something
    > > > > stupid-wrong. Anyone help?

    >
    > > > > public class SDNetLabelTextBox : ContainerBase,
    > > > > ICompositeControlDesignerAccessor, ISDNetControl
    > > > > {
    > > > > private Label _label;

    >
    > > > > public SDNetLabelTextBox()
    > > > > {
    > > > > this._label = new Label();
    > > > > this._label.ID += "_SDLabel";
    > > > > this._label.Text = "SDNet LabelTextBox";
    > > > > }

    >
    > > > > public override void RenderControl(HtmlTextWriter writer)
    > > > > {
    > > > > this._label.RenderControl(writer);
    > > > > base.RenderControl(writer);
    > > > > }

    >
    > > > > public Label Label
    > > > > {
    > > > > get { return this._label; }
    > > > > set { this._label = value; }
    > > > > }

    >
    > > > > #region ICompositeControlDesignerAccessor Members

    >
    > > > > void ICompositeControlDesignerAccessor.RecreateChildControls()
    > > > > {
    > > > > base.ChildControlsCreated = false;
    > > > > EnsureChildControls();
    > > > > }

    >
    > > > > #endregion

    >
    > > > So, nobody has any idea why this doesn't work?- Hide quoted text -

    >
    > > > - Show quoted text -

    >
    > > Ok.. here is what I have found to work so far...

    >
    > > If I create a custom control and derive it from a base web control and
    > > then add the [NotifyParentProperty(true)] attribute to the overriden
    > > property I want to update in the designer (e.g. Text property of the
    > > label) and use my custom control instead of the standard control.
    > > Everything updates for the property.

    >
    > > public class SDNetLabel : Label
    > > {
    > > [NotifyParentProperty(true)]
    > > public override string Text
    > > {
    > > get
    > > {
    > > return base.Text;
    > > }
    > > set
    > > {
    > > base.Text = value;
    > > }
    > > }

    >
    > > [NotifyParentProperty(true)]
    > > public override System.Drawing.Color ForeColor
    > > {
    > > get
    > > {
    > > return base.ForeColor;
    > > }
    > > set
    > > {
    > > base.ForeColor = value;
    > > }
    > > }

    >
    > > }

    >
    > > Is there a property or attribute that can be specified on the web
    > > controls to make them always update the parent when a property changes
    > > or am I stuck writing derived controls just to set an attribute on the
    > > properties I want updated via the designer?

    >
    > > Bob- Hide quoted text -

    >
    > > - Show quoted text -- Hide quoted text -

    >
    > - Show quoted text -


    I found this link with basically the same problem. Fine. Marked, But
    is there a way around this?


    http://groups.google.com/group/micr... persist values&rnum=6&hl=en#5aae76e49dead72e
    Bob Jones, Apr 9, 2007
    #5
    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. Ben
    Replies:
    2
    Views:
    867
  2. Lawrence D'Oliveiro

    Death To Sub-Sub-Sub-Directories!

    Lawrence D'Oliveiro, May 5, 2011, in forum: Java
    Replies:
    92
    Views:
    1,979
    Lawrence D'Oliveiro
    May 20, 2011
  3. William French

    rendering derived control from composite control

    William French, Dec 2, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    207
    Wayne
    Dec 3, 2003
  4. Aaron Prohaska

    Composite control not rendering

    Aaron Prohaska, Jan 13, 2004, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    144
    Victor Garcia Aprea [MVP]
    Jan 22, 2004
  5. Chad
    Replies:
    0
    Views:
    214
Loading...

Share This Page