Hi Mark,
I'm not very clear about your question. For a simple property that needs to
assign to the constituent control, if you do that in CreateChildControls,
you will notice you don't need to do anything to update the designer since
the CreateChildControls will be called again to update the designer when
the property is changed. Here's a test:
1) Suppose we have following simple CompositeControl:
public class Class1 : CompositeControl
{
private Label m_lblName;
public string NameLabel
{
get {
Debug.WriteLine("NameLabel Getter");
return ViewState["NameLabel"] as string;
}
set {
Debug.WriteLine("NameLabel Setter");
ViewState["NameLabel"] = value;
}
}
protected override void CreateChildControls()
{
Debug.WriteLine("CreateChildControls");
Controls.Clear();
m_lblName = new Label();
m_lblName.ID = "lblName";
m_lblName.Text = NameLabel;
Controls.Add(m_lblName);
}
}
2) Use this control in a WebForm and change its NameLabel property, make
sure you have turned on Debug in compilation options; and use DebugView
from sysinternals to view the output. You will notice every time you change
the NameLabel property, the CreateChildControls will get called again.
I understand in your specific case, you're using your own designer, the
behavior will be controlled by the designer. Would you please tell me more
about your custom designer and what's your objective to achieve when using
it?
Based on my understanding, when a property is changed, OnComponentChanged
will be called and you will know a property is changed. On the other hand,
if you changed a property in code and want to update the designer surface,
you need to call this method.
#ControlDesigner.OnComponentChanged Method (System.Web.UI.Design)
http://msdn2.microsoft.com/en-us/library/system.web.ui.design.controldesigne
r.oncomponentchanged.aspx
If in doubt, please send me a simple but complete project to demonstrate
the issue.
Sincerely,
Walter Wang (
[email protected], remove 'online.')
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.