Dynamic Menu Control in ASP.NET2

Discussion in 'ASP .Net Web Controls' started by Sri Reddy, May 2, 2006.

  1. Sri Reddy

    Sri Reddy Guest

    Hi
    I want to create a horizontal menu on my website being built using
    asp.net2 with menu items based on the "role" of the user who logged into
    the system.Role iformation will be read from database...

    For ex:
    for a user with "Admin" role, i would like to show "Menu Item1", "Menu
    Item2", "Menu Item3", "Menu Item4". Where as if the user belongs to
    "Help-desk" role, i would like to show only "Menu Item1" and "Menu
    Item3"...

    Also, i want to provide an alternative to access "Menu Items" if the
    java-script is disabled...

    Wondering what options do i got....
    Thanks
    Sri



    *** Sent via Developersdex http://www.developersdex.com ***
     
    Sri Reddy, May 2, 2006
    #1
    1. Advertising

  2. Sri Reddy

    Kelly Leahy Guest

    I don't know about the non-javascript support - you'd probably have to do
    something with a vertical menu for that - horizontal ones get a bit unwieldy
    when they have to be static.

    As for doing the horizontal dynamic menu, the way I did it was with a
    SiteMap file and setting role-based access to folders under the site (Admin
    folder, Members folder, etc.). Then, you can turn on role-checking in the
    web.config file. Alternatively (and a bit faster) you can use the roles
    attribute in the entries in the sitemap (see help on site maps for the
    syntax).

    My menu looks like:
    <asp:Menu ID="Menu1" runat="server" BackColor="#AFBFFF"
    DynamicHorizontalOffset="2"
    DataSourceID="SiteMapDS"
    Font-Names="Verdana" Font-Size="0.8em" ForeColor="#666666"
    ItemWrap="True" Orientation="Horizontal" StaticSubMenuIndent="10px">
    <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
    <DynamicHoverStyle BackColor="#666666" ForeColor="White" />
    <DynamicMenuStyle BackColor="#AFBFFF" BorderColor="#D1DDF1"
    BorderStyle="Solid" BorderWidth="1px"/>
    <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
    <StaticHoverStyle BackColor="#666666" ForeColor="White" />
    </asp:Menu>
    <asp:SiteMapDataSource runat="server" ID="SiteMapDS"
    ShowStartingNode="false" />

    not sure if all the <StaticXXX> tags are needed - they are there for
    historical reasons on my site ;)

    In my web.config, I have:
    <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
    <providers>
    <clear/>
    <add name="XmlSiteMapProvider"
    description="Default SiteMap provider."
    type="System.Web.XmlSiteMapProvider "
    siteMapFile="Web.sitemap"
    securityTrimmingEnabled="true" />
    </providers>
    </siteMap>

    Cheers,
    Kelly

    "Sri Reddy" wrote:

    >
    >
    >
    > Hi
    > I want to create a horizontal menu on my website being built using
    > asp.net2 with menu items based on the "role" of the user who logged into
    > the system.Role iformation will be read from database...
    >
    > For ex:
    > for a user with "Admin" role, i would like to show "Menu Item1", "Menu
    > Item2", "Menu Item3", "Menu Item4". Where as if the user belongs to
    > "Help-desk" role, i would like to show only "Menu Item1" and "Menu
    > Item3"...
    >
    > Also, i want to provide an alternative to access "Menu Items" if the
    > java-script is disabled...
    >
    > Wondering what options do i got....
    > Thanks
    > Sri
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    >
     
    Kelly Leahy, May 2, 2006
    #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. ad
    Replies:
    0
    Views:
    2,504
  2. Sri Reddy
    Replies:
    5
    Views:
    6,374
    prashiddha
    Dec 15, 2011
  3. Replies:
    2
    Views:
    671
  4. Sri Reddy
    Replies:
    3
    Views:
    365
    Jules
    Jun 21, 2006
  5. Mikeg

    Changing default behaviour of ASP.NET2 Menu control

    Mikeg, Jun 19, 2006, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    147
    Mikeg
    Jun 20, 2006
Loading...

Share This Page