Custom Control - inherit child properties?

Discussion in 'ASP .Net Building Controls' started by Andrew, Jul 16, 2003.

  1. Andrew

    Andrew Guest

    Hey All,
    I'm building a custom control that contains a
    System.Web.UI.WebControls.Calendar object and am wondering about how to
    make the calendar's many properties appear in my control's property
    window. I could make a bunch of public properties like
    Calendar_TodayBackColor, and map them internally to <internal calendar
    object>.TodayDayStyle.BackColor, but there are SO many! There must be an
    easier way.

    TIA,
    Andrew
     
    Andrew, Jul 16, 2003
    #1
    1. Advertisements

  2. Hi Andrew,

    Not sure if I'm getting right your question. If you inherit from Calendar
    then all Calendar's public properties will be already shown in the
    properties window. Now, for any new property added to your type you will
    need some code to define it and do any mappings, ie:
    [C#]
    public YourPropertyType YourPropertyName{
    get{ return MappedPropertyName;}
    set{ MappedPropertyName = value;}
    }

    The properties window will automatically show this new public property.

    If you're looking for something different, please give some more details
    about it,

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    http://obies.com/vga/blog.aspx
    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    and not by private mail.
     
    Victor Garcia Aprea [MVP], Jul 16, 2003
    #2
    1. Advertisements

  3. Andrew

    Andrew Guest

    Hi Victor,

    Actually, my control inherits directly from
    System.Web.UI.WebControls.WebControl, not Calendar. It is a custom
    control made up of a textbox, and imagebutton, and a calendar. I was just
    hoping that since the calendar has probably over a hundred seperate style
    properties, there would be some way to "automagically" add them to my
    control's property window instead of making over a hundred seperate public
    properties....
     
    Andrew, Jul 16, 2003
    #3
  4. Ok, what you can do is to create a custom designer (see
    System.Web.UI.Design.ControlDesigner) for your control and make it provide
    all the properties you want (see ControlDesigner.PreFilterProperties). This
    way you dont have to actually add new properties to your custom control.

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    http://obies.com/vga/blog.aspx
    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    and not by private mail.

     
    Victor Garcia Aprea [MVP], Jul 16, 2003
    #4
  5. Andrew

    Andrew Guest

    Excellent, i'll start looking into the ControlDesigner.PreFilterPrperties.
    You wouldn't happen to know of any good samples anywhere would you, MSDN
    is pretty sad when it comes to sample code...
     
    Andrew, Jul 17, 2003
    #5
  6. I don't have any simple samples handy. Do a quick search on
    msdn.microsoft.com for articles written by Shawn Burke (MS), he has couple
    of very good articles about design-time stuff, including the use of
    PreFilterProperties if I remember correctly.

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    http://obies.com/vga/blog.aspx
    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    and not by private mail.
     
    Victor Garcia Aprea [MVP], Jul 17, 2003
    #6
  7. Andrew

    Andrew Guest

    Andrew, Jul 17, 2003
    #7
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.