How to build dynamicaly a menu in ASP.Net 2.0 (VS 2005) ?

Discussion in 'ASP .Net Web Controls' started by MarioSerrano, Nov 17, 2005.

  1. MarioSerrano

    MarioSerrano Guest

    I have a menu (new feature of framework 2.0) in an Web application. The thing
    is, that i already have a function to create a dynamic menu. And it works...
    but the issue is that it doesnt want to show at the page...

    HTML code...
    <asp:Menu ID="Menu1" runat="server" BackColor="#FFFBD6"
    DynamicHorizontalOffset="2"
    Font-Bold="True" Font-Names="Verdana"
    Font-Size="XX-Small" ForeColor="#990000"
    Orientation="Horizontal"
    StaticSubMenuIndent="10px" Width="37px" BorderStyle="Groove" >
    <StaticMenuItemStyle HorizontalPadding="5px"
    VerticalPadding="2px" />
    <DynamicHoverStyle BackColor="#990000"
    ForeColor="White" />
    <DynamicMenuStyle BackColor="#FFFBD6" />
    <StaticSelectedStyle BackColor="#FFCC66" />
    <DynamicSelectedStyle BackColor="#FFCC66" />
    <DynamicMenuItemStyle HorizontalPadding="5px"
    VerticalPadding="2px" />

    <StaticHoverStyle BackColor="#990000"
    ForeColor="White" />
    </asp:Menu>


    // Heres the code

    protected void Page_Load(object sender, System.EventArgs e)
    {
    if (!IsPostBack)
    {
    this.Menu1 = BuildMenu(mySessionVariable);
    }
    }

    // As you can see ,at html code i dont create menu items... even if i
    create menu // items it still doesnt show my created menu ... i dont know
    what i am missing
    // im new at vs 2005 and im meeting some differences between frameworks
    // 1.1 and 2.0... may be its a little issue... hope u can help me


    thanks

    Mario Serrano Flores
    MarioSerrano, Nov 17, 2005
    #1
    1. Advertising

  2. MarioSerrano

    clintonG Guest

    Uh, how could a menu control work if it can't be seen in the page?
    Secondly, your Page_Load event only loads the control if the page is not a
    PostBack. How is the control loaded when the page IS a PostBack or when the
    page is first loaded?

    <%= Clinton Gallagher

    "MarioSerrano" <> wrote in message
    news:...
    >I have a menu (new feature of framework 2.0) in an Web application. The
    >thing
    > is, that i already have a function to create a dynamic menu. And it
    > works...
    > but the issue is that it doesnt want to show at the page...
    >
    > HTML code...
    > <asp:Menu ID="Menu1" runat="server" BackColor="#FFFBD6"
    > DynamicHorizontalOffset="2"
    > Font-Bold="True" Font-Names="Verdana"
    > Font-Size="XX-Small" ForeColor="#990000"
    > Orientation="Horizontal"
    > StaticSubMenuIndent="10px" Width="37px" BorderStyle="Groove" >
    > <StaticMenuItemStyle HorizontalPadding="5px"
    > VerticalPadding="2px" />
    > <DynamicHoverStyle BackColor="#990000"
    > ForeColor="White" />
    > <DynamicMenuStyle BackColor="#FFFBD6" />
    > <StaticSelectedStyle BackColor="#FFCC66" />
    > <DynamicSelectedStyle BackColor="#FFCC66" />
    > <DynamicMenuItemStyle HorizontalPadding="5px"
    > VerticalPadding="2px" />
    >
    > <StaticHoverStyle BackColor="#990000"
    > ForeColor="White" />
    > </asp:Menu>
    >
    >
    > // Heres the code
    >
    > protected void Page_Load(object sender, System.EventArgs e)
    > {
    > if (!IsPostBack)
    > {
    > this.Menu1 = BuildMenu(mySessionVariable);
    > }
    > }
    >
    > // As you can see ,at html code i dont create menu items... even if i
    > create menu // items it still doesnt show my created menu ... i dont know
    > what i am missing
    > // im new at vs 2005 and im meeting some differences between frameworks
    > // 1.1 and 2.0... may be its a little issue... hope u can help me
    >
    >
    > thanks
    >
    > Mario Serrano Flores
    >
    clintonG, Nov 20, 2005
    #2
    1. Advertising

  3. MarioSerrano

    MarioSerrano Guest

    Uh,mm...

    i fixed the problem....

    i had to send the menu into the function like this...


    BuildMenu(mySessionVariable, this.Menu1);


    ... i really dont know why the function didnt assign correctly the built
    menu...
    but this way worked fine... hope somebody can explain why ...


    thanks = )
    MarioSerrano, Nov 20, 2005
    #3
    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. Bisser Milanov
    Replies:
    2
    Views:
    531
    Bisser Milanov
    Jun 26, 2003
  2. Marc Nederhoff

    Adding style sheet dynamicaly

    Marc Nederhoff, Nov 5, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    423
    charles
    Nov 5, 2003
  3. moondaddy
    Replies:
    7
    Views:
    2,807
    Steven Cheng[MSFT]
    Feb 12, 2004
  4. Replies:
    2
    Views:
    423
    nfedin
    Mar 4, 2004
  5. Totto
    Replies:
    6
    Views:
    2,259
    Totto
    Aug 22, 2006
Loading...

Share This Page