Creating Menu controls on the fly

Discussion in 'ASP .Net Building Controls' started by ree32, Sep 8, 2004.

  1. ree32

    ree32 Guest

    I am reading off menu items from an XML file.

    The problem I have is how to create these menu items into link buttons
    on the fly. As the number of menu items will vary depending on the
    contents of the xml file. So I cannot initialise these all these link
    buttons one by one at start.

    So I was wondering whether there was a way to dynamically create them?
    ree32, Sep 8, 2004
    #1
    1. Advertising

  2. ree32

    Joerg Jooss Guest

    ree32 wrote:
    > I am reading off menu items from an XML file.
    >
    > The problem I have is how to create these menu items into link buttons
    > on the fly. As the number of menu items will vary depending on the
    > contents of the xml file. So I cannot initialise these all these link
    > buttons one by one at start.
    >
    > So I was wondering whether there was a way to dynamically create them?


    If all you need are simple hyperlinks, you could use the Xml WebControl and
    apply an XSLT transformation to create HTML directly from your XML source.

    If you need to have server controls, you could write a composite control
    that parses the XML file and creates a LinkButton for each entry of the XML
    file in CreateChildControls(), but there are some tricky things to consider
    when using the second approach. Do you need server controls?

    Cheers,

    --
    Joerg Jooss
    Joerg Jooss, Sep 8, 2004
    #2
    1. Advertising

  3. ree32

    ree32 Guest

    Server controls would be needed. As what I am trying to build
    something similar to a tree structure menu. So I need menu items to
    collapse depending on whether a toggle switch has been pressed.

    I will go and and read more about composite controls to see if its
    applicable to my case.


    "Joerg Jooss" <> wrote in message news:<>...

    > If you need to have server controls, you could write a composite control
    > that parses the XML file and creates a LinkButton for each entry of the XML
    > file in CreateChildControls(), but there are some tricky things to consider
    > when using the second approach. Do you need server controls?
    >
    > Cheers,
    ree32, Sep 8, 2004
    #3
  4. ree32

    Joerg Jooss Guest

    ree32 wrote:
    > Server controls would be needed. As what I am trying to build
    > something similar to a tree structure menu. So I need menu items to
    > collapse depending on whether a toggle switch has been pressed.
    >
    > I will go and and read more about composite controls to see if its
    > applicable to my case.


    Composite controls are just a special breed of server controls. Instead of
    creating markup language output in Render(), you create child server
    controls in CreateChildControls(). A keypad composed of Button controls is a
    good example.

    Cheers,

    --
    Joerg Jooss
    Joerg Jooss, Sep 9, 2004
    #4
    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. Ryan Ternier
    Replies:
    0
    Views:
    303
    Ryan Ternier
    Aug 4, 2005
  2. theo
    Replies:
    2
    Views:
    596
    David Dorward
    Feb 9, 2005
  3. Hayden Kirk

    Creating Dynamic Controls on the fly

    Hayden Kirk, Apr 2, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    270
    =?Utf-8?B?UGFydmF0aHkgUGFkbWFuYWJoYW4=?=
    Apr 2, 2007
  4. Derk

    Building a menu 'on the fly'

    Derk, Apr 30, 2004, in forum: ASP General
    Replies:
    2
    Views:
    83
    John Blessing
    May 1, 2004
  5. Brian

    Fly outmenu on the fly

    Brian, Apr 8, 2005, in forum: Javascript
    Replies:
    0
    Views:
    95
    Brian
    Apr 8, 2005
Loading...

Share This Page