Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Composite control - sub control as a property not rendering

Reply
Thread Tools

Composite control - sub control as a property not rendering

 
 
Bob Jones
Guest
Posts: n/a
 
      04-06-2007
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.RecreateChildCon trols()
{
base.ChildControlsCreated = false;
EnsureChildControls();
}

#endregion

 
Reply With Quote
 
 
 
 
Bob Jones
Guest
Posts: n/a
 
      04-09-2007
On Apr 6, 11:49 am, "Bob Jones" <(E-Mail Removed)> 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.RecreateChildCon trols()
> {
> base.ChildControlsCreated = false;
> EnsureChildControls();
> }
>
> #endregion


So, nobody has any idea why this doesn't work?

 
Reply With Quote
 
 
 
 
Bob Jones
Guest
Posts: n/a
 
      04-09-2007
On Apr 8, 11:32 pm, "Bob Jones" <(E-Mail Removed)> wrote:
> On Apr 6, 11:49 am, "Bob Jones" <(E-Mail Removed)> 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.RecreateChildCon trols()
> > {
> > 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

 
Reply With Quote
 
Bob Jones
Guest
Posts: n/a
 
      04-09-2007
On Apr 9, 12:22 pm, "Bob Jones" <(E-Mail Removed)> wrote:
> On Apr 8, 11:32 pm, "Bob Jones" <(E-Mail Removed)> wrote:
>
>
>
>
>
> > On Apr 6, 11:49 am, "Bob Jones" <(E-Mail Removed)> 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.RecreateChildCon trols()
> > > {
> > > 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 -



 
Reply With Quote
 
Bob Jones
Guest
Posts: n/a
 
      04-09-2007
On Apr 9, 2:41 pm, "Bob Jones" <(E-Mail Removed)> wrote:
> On Apr 9, 12:22 pm, "Bob Jones" <(E-Mail Removed)> wrote:
>
>
>
> > On Apr 8, 11:32 pm, "Bob Jones" <(E-Mail Removed)> wrote:

>
> > > On Apr 6, 11:49 am, "Bob Jones" <(E-Mail Removed)> 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.RecreateChildCon trols()
> > > > {
> > > > 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/micro...ae76e49dead72e

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Death To Sub-Sub-Sub-Directories! Lawrence D'Oliveiro Java 92 05-20-2011 06:50 AM
Recognising Sub-Items and sub-sub items using xslt Ben XML 2 09-19-2007 09:35 AM
Losing Composite Control property that another Composite Control ... Chad ASP .Net Building Controls 0 02-01-2005 09:01 PM
Possible to create a composite control that has a child control that is a validator that validates the composite control itself? Jonathan Eric Miller ASP .Net Building Controls 2 07-22-2004 10:58 PM
rendering derived control from composite control William French ASP .Net Building Controls 1 12-03-2003 01:20 AM



Advertisments