Composite Control and accessing complex properties of child controls - C# VS2005

Discussion in 'ASP .Net Building Controls' started by Paul Yanzick, Dec 29, 2005.

  1. Paul Yanzick

    Paul Yanzick Guest

    Hello,

    I am trying to build a composite control that contains a few objects, in
    particular a calendar and a textbox.

    I have the bulk of the control built, however I would like to make some of
    the properties present at design time, however I am having some difficulty
    doing so. In particular, I would like to make the style settings for the
    calendar available to the designer, for example the DayStyle. I know it
    uses a TableItemStyle, however I cannot seem to write a property that will
    make it available in the designer.

    Any suggestions on how I would do this, or perhaps some sample code?

    Thanks
    Paul
     
    Paul Yanzick, Dec 29, 2005
    #1
    1. Advertising

  2. Hi Paul,

    Welcome to ASPNET newsgroup.
    From your description, you're developing an ASP.NET 2.0 Custom WEbServer
    control which using Composite control style and will contain some sub
    controls like Calendar... Now you're wondering how to add some public
    style properties in your custom control (mapping to some of the contained
    sub control's properties ) and can utilize the design-time services , yes?

    Based on my experience, the simplest and quickest means is just defining
    some public properties(of the same type of those in the sub controls....)
    in your custom control. To utilize VS ide's design-time feautre, we need to
    apply some certain attributes. I've just created a simple composite control
    which contains a Calendar control and expose a "CalendarDayStyle" property
    to let end user configure inner Calendar control's daystyle through our
    custom control's property. The "CalendarDayStyle" can be configured
    through design-time property grid or in aspx template.... We can retrieve
    the value at runtime and merge with the inner calendar's style....:

    ====================================
    namespace ControlLib
    {
    [DefaultProperty("Text")]
    [ToolboxData("<{0}:MultiCS runat=server></{0}:MultiCS>")]
    [Designer(typeof(MultiCSDesigner),typeof(IDesigner))]
    public class MultiCS : WebControl, INamingContainer
    {
    private Calendar _calendar = null;

    private TableItemStyle _calendarDayStyle = null;



    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
    PersistenceMode(PersistenceMode.InnerProperty),
    DefaultValue((string)null), NotifyParentProperty(true)]
    public TableItemStyle CalendarDayStyle
    {
    get {

    if (this._calendarDayStyle == null)
    {
    this._calendarDayStyle = new TableItemStyle();
    }
    return this._calendarDayStyle;
    }
    }




    [Bindable(true)]
    [Category("Appearance")]
    [DefaultValue("")]
    [Localizable(true)]
    public string Text
    {
    get
    {
    String s = (String)ViewState["Text"];
    return ((s == null) ? String.Empty : s);
    }

    set
    {
    ViewState["Text"] = value;
    }
    }




    protected override void CreateChildControls()
    {
    Controls.Clear();

    _calendar = new Calendar();
    _calendar.ID = "cdrMain";
    _calendar.SelectedDate = DateTime.Now;
    _calendar.VisibleDate = DateTime.Now;

    Controls.Add(_calendar);
    }


    protected override void OnPreRender(EventArgs e)
    {
    base.OnPreRender(e);

    _calendar.DayStyle.MergeWith(_calendarDayStyle);
    }
    }


    public class MultiCSDesigner : ControlDesigner
    {
    public override string GetDesignTimeHtml()
    {
    StringBuilder sb = new StringBuilder();
    sb.Append("<font size='30' red='red'>");
    sb.Append("MultiCS DesignTime......");
    sb.Append("</font>");

    return sb.ToString();
    }


    }
    }
    ===================================

    Hope helps. Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)




    --------------------
    | From: "Paul Yanzick" <>
    | Subject: Composite Control and accessing complex properties of child
    controls - C# VS2005
    | Date: Thu, 29 Dec 2005 15:54:37 -0600
    | Lines: 18
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
    | X-RFC2646: Format=Flowed; Original
    | Message-ID: <#>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
    | NNTP-Posting-Host: host-189-156-220-24.midco.net 24.220.156.189
    | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
    | Xref: TK2MSFTNGXA02.phx.gbl
    microsoft.public.dotnet.framework.aspnet.buildingcontrols:14190
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
    |
    | Hello,
    |
    | I am trying to build a composite control that contains a few objects, in
    | particular a calendar and a textbox.
    |
    | I have the bulk of the control built, however I would like to make some
    of
    | the properties present at design time, however I am having some
    difficulty
    | doing so. In particular, I would like to make the style settings for the
    | calendar available to the designer, for example the DayStyle. I know it
    | uses a TableItemStyle, however I cannot seem to write a property that
    will
    | make it available in the designer.
    |
    | Any suggestions on how I would do this, or perhaps some sample code?
    |
    | Thanks
    | Paul
    |
    |
    |
     
    Steven Cheng[MSFT], Dec 30, 2005
    #2
    1. Advertising

  3. Hi Paul,

    Does my suggestion in last reply helps a little? If there're anything else
    we can help, please feel free to post here.

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    --------------------
    | X-Tomcat-ID: 100390610
    | References: <#>
    | MIME-Version: 1.0
    | Content-Type: text/plain
    | Content-Transfer-Encoding: 7bit
    | From: (Steven Cheng[MSFT])
    | Organization: Microsoft
    | Date: Fri, 30 Dec 2005 06:15:04 GMT
    | Subject: RE: Composite Control and accessing complex properties of child
    controls - C# VS2005
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
    | Message-ID: <>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
    | Lines: 128
    | Path: TK2MSFTNGXA02.phx.gbl
    | Xref: TK2MSFTNGXA02.phx.gbl
    microsoft.public.dotnet.framework.aspnet.buildingcontrols:14202
    | NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
    |
    | Hi Paul,
    |
    | Welcome to ASPNET newsgroup.
    | From your description, you're developing an ASP.NET 2.0 Custom WEbServer
    | control which using Composite control style and will contain some sub
    | controls like Calendar... Now you're wondering how to add some public
    | style properties in your custom control (mapping to some of the contained
    | sub control's properties ) and can utilize the design-time services , yes?
    |
    | Based on my experience, the simplest and quickest means is just defining
    | some public properties(of the same type of those in the sub controls....)
    | in your custom control. To utilize VS ide's design-time feautre, we need
    to
    | apply some certain attributes. I've just created a simple composite
    control
    | which contains a Calendar control and expose a "CalendarDayStyle"
    property
    | to let end user configure inner Calendar control's daystyle through our
    | custom control's property. The "CalendarDayStyle" can be configured
    | through design-time property grid or in aspx template.... We can retrieve
    | the value at runtime and merge with the inner calendar's style....:
    |
    | ====================================
    | namespace ControlLib
    | {
    | [DefaultProperty("Text")]
    | [ToolboxData("<{0}:MultiCS runat=server></{0}:MultiCS>")]
    | [Designer(typeof(MultiCSDesigner),typeof(IDesigner))]
    | public class MultiCS : WebControl, INamingContainer
    | {
    | private Calendar _calendar = null;
    |
    | private TableItemStyle _calendarDayStyle = null;
    |
    |
    |
    |
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
    | PersistenceMode(PersistenceMode.InnerProperty),
    | DefaultValue((string)null), NotifyParentProperty(true)]
    | public TableItemStyle CalendarDayStyle
    | {
    | get {
    |
    | if (this._calendarDayStyle == null)
    | {
    | this._calendarDayStyle = new TableItemStyle();
    | }
    | return this._calendarDayStyle;
    | }
    | }
    |
    |
    |
    |
    | [Bindable(true)]
    | [Category("Appearance")]
    | [DefaultValue("")]
    | [Localizable(true)]
    | public string Text
    | {
    | get
    | {
    | String s = (String)ViewState["Text"];
    | return ((s == null) ? String.Empty : s);
    | }
    |
    | set
    | {
    | ViewState["Text"] = value;
    | }
    | }
    |
    |
    |
    |
    | protected override void CreateChildControls()
    | {
    | Controls.Clear();
    |
    | _calendar = new Calendar();
    | _calendar.ID = "cdrMain";
    | _calendar.SelectedDate = DateTime.Now;
    | _calendar.VisibleDate = DateTime.Now;
    |
    | Controls.Add(_calendar);
    | }
    |
    |
    | protected override void OnPreRender(EventArgs e)
    | {
    | base.OnPreRender(e);
    |
    | _calendar.DayStyle.MergeWith(_calendarDayStyle);
    | }
    | }
    |
    |
    | public class MultiCSDesigner : ControlDesigner
    | {
    | public override string GetDesignTimeHtml()
    | {
    | StringBuilder sb = new StringBuilder();
    | sb.Append("<font size='30' red='red'>");
    | sb.Append("MultiCS DesignTime......");
    | sb.Append("</font>");
    |
    | return sb.ToString();
    | }
    |
    |
    | }
    | }
    | ===================================
    |
    | Hope helps. Thanks,
    |
    | Steven Cheng
    | Microsoft Online Support
    |
    | Get Secure! www.microsoft.com/security
    | (This posting is provided "AS IS", with no warranties, and confers no
    | rights.)
    |
    |
    |
    |
    | --------------------
    | | From: "Paul Yanzick" <>
    | | Subject: Composite Control and accessing complex properties of child
    | controls - C# VS2005
    | | Date: Thu, 29 Dec 2005 15:54:37 -0600
    | | Lines: 18
    | | X-Priority: 3
    | | X-MSMail-Priority: Normal
    | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
    | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
    | | X-RFC2646: Format=Flowed; Original
    | | Message-ID: <#>
    | | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
    | | NNTP-Posting-Host: host-189-156-220-24.midco.net 24.220.156.189
    | | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
    | | Xref: TK2MSFTNGXA02.phx.gbl
    | microsoft.public.dotnet.framework.aspnet.buildingcontrols:14190
    | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
    | |
    | | Hello,
    | |
    | | I am trying to build a composite control that contains a few objects,
    in
    | | particular a calendar and a textbox.
    | |
    | | I have the bulk of the control built, however I would like to make some
    | of
    | | the properties present at design time, however I am having some
    | difficulty
    | | doing so. In particular, I would like to make the style settings for
    the
    | | calendar available to the designer, for example the DayStyle. I know
    it
    | | uses a TableItemStyle, however I cannot seem to write a property that
    | will
    | | make it available in the designer.
    | |
    | | Any suggestions on how I would do this, or perhaps some sample code?
    | |
    | | Thanks
    | | Paul
    | |
    | |
    | |
    |
    |
     
    Steven Cheng[MSFT], Jan 4, 2006
    #3
  4. Paul Yanzick

    Paul Yanzick Guest

    Hello,

    Sorry I haven't replied. Was preoccupied with some other projects.

    I believe that this will help, thank you! I think I tried something along
    the same lines, but what you have here is slightly different so I will give
    that a shot.

    Thanks!
    Paul
    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Paul,
    >
    > Does my suggestion in last reply helps a little? If there're anything else
    > we can help, please feel free to post here.
    >
    > Regards,
    >
    > Steven Cheng
    > Microsoft Online Support
    >
    > Get Secure! www.microsoft.com/security
    > (This posting is provided "AS IS", with no warranties, and confers no
    > rights.)
    > --------------------
    > | X-Tomcat-ID: 100390610
    > | References: <#>
    > | MIME-Version: 1.0
    > | Content-Type: text/plain
    > | Content-Transfer-Encoding: 7bit
    > | From: (Steven Cheng[MSFT])
    > | Organization: Microsoft
    > | Date: Fri, 30 Dec 2005 06:15:04 GMT
    > | Subject: RE: Composite Control and accessing complex properties of child
    > controls - C# VS2005
    > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
    > | Message-ID: <>
    > | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
    > | Lines: 128
    > | Path: TK2MSFTNGXA02.phx.gbl
    > | Xref: TK2MSFTNGXA02.phx.gbl
    > microsoft.public.dotnet.framework.aspnet.buildingcontrols:14202
    > | NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
    > |
    > | Hi Paul,
    > |
    > | Welcome to ASPNET newsgroup.
    > | From your description, you're developing an ASP.NET 2.0 Custom WEbServer
    > | control which using Composite control style and will contain some sub
    > | controls like Calendar... Now you're wondering how to add some public
    > | style properties in your custom control (mapping to some of the
    > contained
    > | sub control's properties ) and can utilize the design-time services ,
    > yes?
    > |
    > | Based on my experience, the simplest and quickest means is just defining
    > | some public properties(of the same type of those in the sub
    > controls....)
    > | in your custom control. To utilize VS ide's design-time feautre, we need
    > to
    > | apply some certain attributes. I've just created a simple composite
    > control
    > | which contains a Calendar control and expose a "CalendarDayStyle"
    > property
    > | to let end user configure inner Calendar control's daystyle through our
    > | custom control's property. The "CalendarDayStyle" can be configured
    > | through design-time property grid or in aspx template.... We can
    > retrieve
    > | the value at runtime and merge with the inner calendar's style....:
    > |
    > | ====================================
    > | namespace ControlLib
    > | {
    > | [DefaultProperty("Text")]
    > | [ToolboxData("<{0}:MultiCS runat=server></{0}:MultiCS>")]
    > | [Designer(typeof(MultiCSDesigner),typeof(IDesigner))]
    > | public class MultiCS : WebControl, INamingContainer
    > | {
    > | private Calendar _calendar = null;
    > |
    > | private TableItemStyle _calendarDayStyle = null;
    > |
    > |
    > |
    > |
    > [DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
    > | PersistenceMode(PersistenceMode.InnerProperty),
    > | DefaultValue((string)null), NotifyParentProperty(true)]
    > | public TableItemStyle CalendarDayStyle
    > | {
    > | get {
    > |
    > | if (this._calendarDayStyle == null)
    > | {
    > | this._calendarDayStyle = new TableItemStyle();
    > | }
    > | return this._calendarDayStyle;
    > | }
    > | }
    > |
    > |
    > |
    > |
    > | [Bindable(true)]
    > | [Category("Appearance")]
    > | [DefaultValue("")]
    > | [Localizable(true)]
    > | public string Text
    > | {
    > | get
    > | {
    > | String s = (String)ViewState["Text"];
    > | return ((s == null) ? String.Empty : s);
    > | }
    > |
    > | set
    > | {
    > | ViewState["Text"] = value;
    > | }
    > | }
    > |
    > |
    > |
    > |
    > | protected override void CreateChildControls()
    > | {
    > | Controls.Clear();
    > |
    > | _calendar = new Calendar();
    > | _calendar.ID = "cdrMain";
    > | _calendar.SelectedDate = DateTime.Now;
    > | _calendar.VisibleDate = DateTime.Now;
    > |
    > | Controls.Add(_calendar);
    > | }
    > |
    > |
    > | protected override void OnPreRender(EventArgs e)
    > | {
    > | base.OnPreRender(e);
    > |
    > | _calendar.DayStyle.MergeWith(_calendarDayStyle);
    > | }
    > | }
    > |
    > |
    > | public class MultiCSDesigner : ControlDesigner
    > | {
    > | public override string GetDesignTimeHtml()
    > | {
    > | StringBuilder sb = new StringBuilder();
    > | sb.Append("<font size='30' red='red'>");
    > | sb.Append("MultiCS DesignTime......");
    > | sb.Append("</font>");
    > |
    > | return sb.ToString();
    > | }
    > |
    > |
    > | }
    > | }
    > | ===================================
    > |
    > | Hope helps. Thanks,
    > |
    > | Steven Cheng
    > | Microsoft Online Support
    > |
    > | Get Secure! www.microsoft.com/security
    > | (This posting is provided "AS IS", with no warranties, and confers no
    > | rights.)
    > |
    > |
    > |
    > |
    > | --------------------
    > | | From: "Paul Yanzick" <>
    > | | Subject: Composite Control and accessing complex properties of child
    > | controls - C# VS2005
    > | | Date: Thu, 29 Dec 2005 15:54:37 -0600
    > | | Lines: 18
    > | | X-Priority: 3
    > | | X-MSMail-Priority: Normal
    > | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
    > | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
    > | | X-RFC2646: Format=Flowed; Original
    > | | Message-ID: <#>
    > | | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
    > | | NNTP-Posting-Host: host-189-156-220-24.midco.net 24.220.156.189
    > | | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
    > | | Xref: TK2MSFTNGXA02.phx.gbl
    > | microsoft.public.dotnet.framework.aspnet.buildingcontrols:14190
    > | | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
    > | |
    > | | Hello,
    > | |
    > | | I am trying to build a composite control that contains a few objects,
    > in
    > | | particular a calendar and a textbox.
    > | |
    > | | I have the bulk of the control built, however I would like to make
    > some
    > | of
    > | | the properties present at design time, however I am having some
    > | difficulty
    > | | doing so. In particular, I would like to make the style settings for
    > the
    > | | calendar available to the designer, for example the DayStyle. I know
    > it
    > | | uses a TableItemStyle, however I cannot seem to write a property that
    > | will
    > | | make it available in the designer.
    > | |
    > | | Any suggestions on how I would do this, or perhaps some sample code?
    > | |
    > | | Thanks
    > | | Paul
    > | |
    > | |
    > | |
    > |
    > |
    >
     
    Paul Yanzick, Jan 6, 2006
    #4
  5. Glad to hear from you Paul,

    If you get any progress, please feel free to post here.

    Regards,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)
    --------------------
    | From: "Paul Yanzick" <>
    | References: <#>
    <>
    <>
    | Subject: Re: Composite Control and accessing complex properties of child
    controls - C# VS2005
    | Date: Fri, 6 Jan 2006 15:48:44 -0600
    | Lines: 226
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
    | X-RFC2646: Format=Flowed; Original
    | Message-ID: <#>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
    | NNTP-Posting-Host: host-189-156-220-24.midco.net 24.220.156.189
    | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
    | Xref: TK2MSFTNGXA02.phx.gbl
    microsoft.public.dotnet.framework.aspnet.buildingcontrols:14241
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
    |
    | Hello,
    |
    | Sorry I haven't replied. Was preoccupied with some other projects.
    |
    | I believe that this will help, thank you! I think I tried something
    along
    | the same lines, but what you have here is slightly different so I will
    give
    | that a shot.
    |
    | Thanks!
    | Paul
    | "Steven Cheng[MSFT]" <> wrote in message
    | news:...
    | > Hi Paul,
    | >
    | > Does my suggestion in last reply helps a little? If there're anything
    else
    | > we can help, please feel free to post here.
    | >
    | > Regards,
    | >
    | > Steven Cheng
    | > Microsoft Online Support
    | >
    | > Get Secure! www.microsoft.com/security
    | > (This posting is provided "AS IS", with no warranties, and confers no
    | > rights.)
    | > --------------------
    | > | X-Tomcat-ID: 100390610
    | > | References: <#>
    | > | MIME-Version: 1.0
    | > | Content-Type: text/plain
    | > | Content-Transfer-Encoding: 7bit
    | > | From: (Steven Cheng[MSFT])
    | > | Organization: Microsoft
    | > | Date: Fri, 30 Dec 2005 06:15:04 GMT
    | > | Subject: RE: Composite Control and accessing complex properties of
    child
    | > controls - C# VS2005
    | > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
    | > | Message-ID: <>
    | > | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
    | > | Lines: 128
    | > | Path: TK2MSFTNGXA02.phx.gbl
    | > | Xref: TK2MSFTNGXA02.phx.gbl
    | > microsoft.public.dotnet.framework.aspnet.buildingcontrols:14202
    | > | NNTP-Posting-Host: TOMCATIMPORT1 10.201.218.122
    | > |
    | > | Hi Paul,
    | > |
    | > | Welcome to ASPNET newsgroup.
    | > | From your description, you're developing an ASP.NET 2.0 Custom
    WEbServer
    | > | control which using Composite control style and will contain some sub
    | > | controls like Calendar... Now you're wondering how to add some public
    | > | style properties in your custom control (mapping to some of the
    | > contained
    | > | sub control's properties ) and can utilize the design-time services ,
    | > yes?
    | > |
    | > | Based on my experience, the simplest and quickest means is just
    defining
    | > | some public properties(of the same type of those in the sub
    | > controls....)
    | > | in your custom control. To utilize VS ide's design-time feautre, we
    need
    | > to
    | > | apply some certain attributes. I've just created a simple composite
    | > control
    | > | which contains a Calendar control and expose a "CalendarDayStyle"
    | > property
    | > | to let end user configure inner Calendar control's daystyle through
    our
    | > | custom control's property. The "CalendarDayStyle" can be configured
    | > | through design-time property grid or in aspx template.... We can
    | > retrieve
    | > | the value at runtime and merge with the inner calendar's style....:
    | > |
    | > | ====================================
    | > | namespace ControlLib
    | > | {
    | > | [DefaultProperty("Text")]
    | > | [ToolboxData("<{0}:MultiCS runat=server></{0}:MultiCS>")]
    | > | [Designer(typeof(MultiCSDesigner),typeof(IDesigner))]
    | > | public class MultiCS : WebControl, INamingContainer
    | > | {
    | > | private Calendar _calendar = null;
    | > |
    | > | private TableItemStyle _calendarDayStyle = null;
    | > |
    | > |
    | > |
    | > |
    | >
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
    | > | PersistenceMode(PersistenceMode.InnerProperty),
    | > | DefaultValue((string)null), NotifyParentProperty(true)]
    | > | public TableItemStyle CalendarDayStyle
    | > | {
    | > | get {
    | > |
    | > | if (this._calendarDayStyle == null)
    | > | {
    | > | this._calendarDayStyle = new TableItemStyle();
    | > | }
    | > | return this._calendarDayStyle;
    | > | }
    | > | }
    | > |
    | > |
    | > |
    | > |
    | > | [Bindable(true)]
    | > | [Category("Appearance")]
    | > | [DefaultValue("")]
    | > | [Localizable(true)]
    | > | public string Text
    | > | {
    | > | get
    | > | {
    | > | String s = (String)ViewState["Text"];
    | > | return ((s == null) ? String.Empty : s);
    | > | }
    | > |
    | > | set
    | > | {
    | > | ViewState["Text"] = value;
    | > | }
    | > | }
    | > |
    | > |
    | > |
    | > |
    | > | protected override void CreateChildControls()
    | > | {
    | > | Controls.Clear();
    | > |
    | > | _calendar = new Calendar();
    | > | _calendar.ID = "cdrMain";
    | > | _calendar.SelectedDate = DateTime.Now;
    | > | _calendar.VisibleDate = DateTime.Now;
    | > |
    | > | Controls.Add(_calendar);
    | > | }
    | > |
    | > |
    | > | protected override void OnPreRender(EventArgs e)
    | > | {
    | > | base.OnPreRender(e);
    | > |
    | > | _calendar.DayStyle.MergeWith(_calendarDayStyle);
    | > | }
    | > | }
    | > |
    | > |
    | > | public class MultiCSDesigner : ControlDesigner
    | > | {
    | > | public override string GetDesignTimeHtml()
    | > | {
    | > | StringBuilder sb = new StringBuilder();
    | > | sb.Append("<font size='30' red='red'>");
    | > | sb.Append("MultiCS DesignTime......");
    | > | sb.Append("</font>");
    | > |
    | > | return sb.ToString();
    | > | }
    | > |
    | > |
    | > | }
    | > | }
    | > | ===================================
    | > |
    | > | Hope helps. Thanks,
    | > |
    | > | Steven Cheng
    | > | Microsoft Online Support
    | > |
    | > | Get Secure! www.microsoft.com/security
    | > | (This posting is provided "AS IS", with no warranties, and confers no
    | > | rights.)
    | > |
    | > |
    | > |
    | > |
    | > | --------------------
    | > | | From: "Paul Yanzick" <>
    | > | | Subject: Composite Control and accessing complex properties of child
    | > | controls - C# VS2005
    | > | | Date: Thu, 29 Dec 2005 15:54:37 -0600
    | > | | Lines: 18
    | > | | X-Priority: 3
    | > | | X-MSMail-Priority: Normal
    | > | | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
    | > | | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
    | > | | X-RFC2646: Format=Flowed; Original
    | > | | Message-ID: <#>
    | > | | Newsgroups:
    microsoft.public.dotnet.framework.aspnet.buildingcontrols
    | > | | NNTP-Posting-Host: host-189-156-220-24.midco.net 24.220.156.189
    | > | | Path:
    TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
    | > | | Xref: TK2MSFTNGXA02.phx.gbl
    | > | microsoft.public.dotnet.framework.aspnet.buildingcontrols:14190
    | > | | X-Tomcat-NG:
    microsoft.public.dotnet.framework.aspnet.buildingcontrols
    | > | |
    | > | | Hello,
    | > | |
    | > | | I am trying to build a composite control that contains a few
    objects,
    | > in
    | > | | particular a calendar and a textbox.
    | > | |
    | > | | I have the bulk of the control built, however I would like to make
    | > some
    | > | of
    | > | | the properties present at design time, however I am having some
    | > | difficulty
    | > | | doing so. In particular, I would like to make the style settings
    for
    | > the
    | > | | calendar available to the designer, for example the DayStyle. I
    know
    | > it
    | > | | uses a TableItemStyle, however I cannot seem to write a property
    that
    | > | will
    | > | | make it available in the designer.
    | > | |
    | > | | Any suggestions on how I would do this, or perhaps some sample code?
    | > | |
    | > | | Thanks
    | > | | Paul
    | > | |
    | > | |
    | > | |
    | > |
    | > |
    | >
    |
    |
    |
     
    Steven Cheng[MSFT], Jan 9, 2006
    #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. Moldy

    Accessing Properties of Custom Controls child Controls

    Moldy, Sep 4, 2003, in forum: ASP .Net Building Controls
    Replies:
    8
    Views:
    226
    Moldy
    Sep 5, 2003
  2. Matt T.

    Composite Control - Viewstate management for complex properties

    Matt T., Sep 7, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    215
    Teemu Keiski
    Sep 11, 2004
  3. Gentian Hila

    complex properties (font) on composite controls

    Gentian Hila, Jan 5, 2006, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    125
    Ken Baltrinic
    Jan 19, 2006
  4. Moldy
    Replies:
    8
    Views:
    251
    Moldy
    Sep 5, 2003
  5. Buddy Ackerman

    Accessing Child Controls in a composite custom control

    Buddy Ackerman, Dec 15, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    132
    Buddy Ackerman
    Dec 15, 2005
Loading...

Share This Page