|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Dynamic Menu Control in ASP.NET2I 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 *** 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 Show quoteHide quote "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 *** >
Failed to load viewstate
Push Button Event in datagrid Web Standards Compliance - Autopostback / Javascript off Automatic <%@Register of Web User Controls in a Project? Disabling certain url's in a menu? Using hyperlink control for downloading User Control question - REPOSTED "Unable to open the physical file" error html controls with same ID Creating Dynamic FormView Templates |
|||||||||||||||||||||||