server control collection with several types of properties

Discussion in 'ASP .Net Building Controls' started by mr dropdown, Dec 25, 2005.

  1. mr dropdown

    mr dropdown Guest

    Is it possible to implement a server control that will look like this:
    <just:control>
    <columns>
    <columnTypeA id=1></columnTypeA>
    <columnTypeA id=2></columnTypeA>
    <columnTypeB id=3></columnTypeB>
    <columnTypeB id=4></columnTypeB>
    </columns>
    </just:control>

    While columnTypeA is a collection and columnTypeB is a different collection?
    Another option is that both tags will be in the same collection (if
    possible..)
    Thanks.
     
    mr dropdown, Dec 25, 2005
    #1
    1. Advertising

  2. mr. dropdown,
    yes this is possible. you need to investigate the ControlBuilder
    class:


    http://msdn.microsoft.com/library/d.../frlrfsystemwebuicontrolbuilderclasstopic.asp

    as this will show you how to parse custom html into strongly typed
    classes. basically, your just:control class will have a ControlBuilder
    attached to it via attributes, ex:

    namespace Just {
    [ControlBuilder(typeof(JustControlBuilder))]
    public class SomeControl : Control {
    }
    }

    first you'll need to build a class that extends the ControlBuilder
    class (JustControlBuilder in the above example). this class has 2
    methods you need to worry about; GetChildControlType and
    AppendLiteralString. before Control.AddParsedSubObject is called,
    SomeControl (above) will call GetChildControlType from your control
    builder, passing the tagname of the html tag its parsing. basically,
    if its a tag you're looking for you return the type of the class it
    represents (see below). AppendLiteralString controls whether literal
    text within your control's boundries will be handled or not.
    next, you'll need a class (extends control) to represent each of the
    items in the dropdown. per your description, you'd basically need 3
    classes; one generic dropdown item class, and 2 collection classes to
    represt itemA and itemB (perhaps one base class both can derive
    from...).
    each of the associated child controls can have their own control
    builders to further parse nested html. the functionality is up to you
    to implement...get as detailed as you'd like.
    here's a link to someone who was having a similar issue (parsing
    nested html), and their resolution:

    http://groups.google.com/group/micr...k=st&q=controlbuilder&rnum=2#1b67c98bae515c20

    hope this helps,
    Mike MacMillan


    mr dropdown wrote:
    > Is it possible to implement a server control that will look like this:
    > <just:control>
    > <columns>
    > <columnTypeA id=1></columnTypeA>
    > <columnTypeA id=2></columnTypeA>
    > <columnTypeB id=3></columnTypeB>
    > <columnTypeB id=4></columnTypeB>
    > </columns>
    > </just:control>
    >
    > While columnTypeA is a collection and columnTypeB is a different collection?
    > Another option is that both tags will be in the same collection (if
    > possible..)
    > Thanks.
     
    Mike MacMillan, Dec 28, 2005
    #2
    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. Brian
    Replies:
    2
    Views:
    2,159
    BMukes
    May 28, 2004
  2. news_server.nc.rr.com
    Replies:
    0
    Views:
    562
    news_server.nc.rr.com
    May 24, 2005
  3. Øyvind Isaksen
    Replies:
    1
    Views:
    1,024
    Øyvind Isaksen
    May 18, 2007
  4. news_server.nc.rr.com

    how can I create a properties collection for a user control

    news_server.nc.rr.com, May 24, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    131
    news_server.nc.rr.com
    May 24, 2005
  5. Victor \Zverok\ Shepelev

    RDOC: several related modules in several C files

    Victor \Zverok\ Shepelev, Mar 6, 2007, in forum: Ruby
    Replies:
    3
    Views:
    197
    Max Lapshin
    Mar 16, 2007
Loading...

Share This Page