Composite control - sub control as a property not rendering

B

Bob Jones

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
 
B

Bob Jones

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

Bob Jones

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
 
B

Bob Jones

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

Bob Jones

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
 

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

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top