.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Dynamic menu control

Posted By:      Posted Date: August 23, 2010    Points: 0   Category :ASP.Net

Dear all,

I want to get the names of some folders in my drive and populate my menu control with the names of those folders.

Getting the folder names is not the issue, but how can i populate my menu with the names of getted foldernames.

I tried this:

DirectoryInfo dirInfo = new DirectoryInfo(Server.MapPath("~\\MyFolders\\"));
DirectoryInfo[] dirs = dirInfo.GetDirectories();
Menu1.DataSource = dirs;

But im getting the error:

HierarchicalDataBoundControl only accepts data sources that implement IHierarchicalDataSource or IHierarchicalEnumerable.


How can i achieve this?

Thanks in advance.


View Complete Post

More Related Resource Links

dynamic menu control call in login page

Hi ,i have declared two control in my master page , how wants to call this menu control in child page ( that is login page)i want to bind the menu control dynamically based on login previlagepublic Menu newMenu = new Menu();  public MenuItem newItem = new MenuItem("Master");

Css menu control with Sitemap, rollover and dynamic images


Hi all

I have been building a site (http://www.leisurepursuits.co.uk) but i am having some trouble.

I built it using a bunch of links with a css rollover style.

However, what i would like to do is a)have sub menu items and b) have it so that the button which relates to the page the user is on is always highlighted.

Now to me, the obvious choice would be to build a sitemap (which i have done) use the menu control (which i have done) apply images to each individual node (i dont know how to do this) create a rollover (i dont know how to do this) and then programatically make it so the button stays highlighted if they are on the relevant page (i dont know how to do this)

So is anyone able to point me in the irght direction for doing the last three at all?

I have been googling for ages and just cannot find a half decent tutorial on the menu control which covers the points i make above.

I would really apreciate your help

Thanks very much

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

"Type ASP.x is not defined" error for dynamic user control when publishing updateable


I have a user control (ContainerCtrl) which programmatically instantiates another user control (SimpleCtrl) in OnLoad. It builds and runs fine, but when I publish it I get the error "error BC30002: Type 'ASP.SimpleCtrl' is not defined." (If I publish without the "updateable" option there's no error, but I need the site to be updateable.)

I assume this has to do with the particulars of how the assembly(ies) are built for the different compiler options. My question is, how can I get it to work properly for "updateable" publishing?

VS 2008 / .NET 3.5 sp1

The code follows (web.config is the default from Visual Studio).

Many thanks, Dave


<%@ Control Language="VB" ClassName="SimpleCtrl" CodeFile="SimpleCtrl.ascx.vb" Inherits="_SimpleCtrl" %>

    Simple control


Partial Class _SimpleCtrl
    Inherits UserControl

    'Nothing to see here.

End Class


<%@ Control Language="VB" CodeFile="ContainerCtrl.ascx.vb" Inherits="_ContainerCtrl"

Menu Control


Hi all

Ive got a Menu Control linked to Web.sitemap but would like a step by step example of how

to make it look and behave like the one I found here:-



Is there somewhere I can download an example of this or one similar?




Menu items of Welcome control behaves incorrect in non-IE browsers.


We are using wss 3.0 sp2

I am referring to the welcome control that is part of standard sharepoint pages. This is the in the masterpage. The welcome contrrol has options such as 'sign-in as different user' , 'signout' and so on. When user takes the mouse and tries to click on the sub-menu it doesn't work as if the menu item is not getting focussed (however up/down arrow with keyboard works fine). 

I know that sharepoint sites are not best when viewed with firefox, safari, chrome etc  but is there a fix for this? Is it do with 'z' index setting or something? Can this be fixed through javascript?  

Please share your views/solution.


Menu control rendering issue with IE8



Using VS2010, I created an ASP.NET 4.0 web application and simply added a couple of menu items below the "Home" menu item in the master page that's created by the project wizard. I made no other changes - no code, no stylesheet changes.

If I run the app locally then everything is fine. I suspect because the local IIS is responsive enough for the problem not to occur.

If I deploy the app to a web host (discountasp.net) then I see the menu render vertically for less than a second before it renders correctly. If I refresh the page a few times then usually I can see the menu vertical flash but sometimes I can't, so there's some sort of timing consideration.

I'm using IE8. The problem doesn't seem to occur with either Firefox 3 or Chrome.

Have others seen this problem?

Any suggestions for a fix?

I can supply the zipped up project if anyone wants it.


Jquery dynamic Category menu


Dear Friends

Im currently developing ecommerce web site. I reffered to some video tutorials in ASP.net website and i managed to develped basic store front for my ecommerce website. I would like give more attractive look to my categories menu using Jquery or ajax. Please someone help me to understand how to apply jquery or ajax to dynamic category menu.

I use web user control to create category menu. This is my code for that.

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CategoriesList.ascx.cs" Inherits="UserControls_CategoriesList" %>
<asp:DataList ID="list" runat="server" CssClass="CategoriesList" Width="200px">
    Choose a Category
  <HeaderStyle CssClass="CategoriesListHead" />
    <asp:HyperLink ID="HyperLink1" Runat="server"
      NavigateUrl='<%# Link.ToCategory(Request.QueryString["DepartmentID"], Eval("CategoryID").ToString()) %>'
      Text='<%# HttpUtility.HtmlEncode(Eval("Name").ToString()) %>'
      ToolTip='<%# HttpUtility.HtmlEncode(Eval("Description").ToString()) %>'

Re;Creating Dynamic Control

Hi, I have a table which stores the data like mentioned below ID Name Values 1 States Karnataka,Tamilnade,AP,UP 2 Karnataka Bangalore, Mysore, Bidar 3 tamilnadu Salem,Chennai,Pondicherry 4 AP Hyderbad,Secunderabad,Vishakapatanam 5 UP Delhi,Agra Now i have to create a dynamic controls for each and every states from the above table. A Sate Name should be dispalyed with checkbox on check of checkbox i have to enable all the cities which is again associated with the checkbox.How do i simulate this functionality using dynamic checkbox and labels. Please help me with a sample code.

problem with menu Control

i am using menu Control and i got a interesting think when i run it through right click and click view in browser then sub menu under menu id display but when i will run it through debug mode then only root is display sub menu is not display.why? 

Menu Control expansion weired issue.

Menu control expands on load (vertically, 100%) and then contracts to its horizontal position. The code I am using- ASPX page: <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="False" IncludeStyleBlock="False" Orientation="Horizontal" DataSourceID="SiteMapDataSource1">                    <DynamicMenuStyle CssClass="DynamicMenu" /></asp:Menu>   CSS:  .DynamicMenu{ display: none;} This can be live at www.jaindata.com Can someone please help? Thanks, Swapneel Shah 

Menu with Static and Dynamic Menu Items

I need to populate a menu with static and dynamic (at runtime) menu items.  I know this issue has been posted before, but I haven't seen anything with a date newer than 2009. This is what I want to do: <Menu> <Menu.ItemsSource>                     <CompositeCollection>                      <MenuItem Header="Menu Item 1" /> <MenuItem Header="Menu Item 2" /> <MenuItem Header="Menu Item 3" />                         <CollectionContainer Collection="{Binding MyMenuItems}" />                     </CompositeCollection> </Menu.ItemsSource> </Menu>   The posts every where say the issue is that CompositeCollection is not freezable.  Regardless of that arguement, has anyone come up with a good solution.  I don't want to create it all in code behind because it is a decent size menu with separators, etc.  This seems like something that should have been fixed or have a decent work round by now.   Thanks. 

The OTHER Menu control issue...

Ok, everyone knows that the z-index is messed up in IE8 and that requires patches or workarounds...What I can't seem to find a solution to is the white background on the DynamicMenu parts of a Menu control.  Setting the background color to transparent or not setting it all doesn't seem to have any effect.  This is only a problem in IE8, Firefox 3.6.8 renders the dynamic menus without the white background.

Dynamic Binding of a Public Property in a User Control

Hi, I am not sure how to pass a variable from an .aspx page to an .ascx page.  I have a Control that puts rotating banners on a page.  The control has several public properties.  However, only one of those properties changes on the page level.  All the other properties are the same for every page site-wide.  So, instead of setting all the properties on every page in my sites (many sites), I want to set it up so I only have to setup the sitewide properties once and only the page level properties on each page.   I want to create a control with a property of AdKeyword="somename" and pass it to another control that will grab that page-level property and add it to all the other site-wide properties.  I guess what I need could be called a Dynamic Control Property.   My .aspx page has:<%@ Register TagPrefix="uc1" TagName="Banner1" Src="banner1.ascx" %> <asp:Content ID="Leaderboard" runat="server" ContentPlaceHolderID="Leaderboard"> <uc1:Banner1 AdKeyword="L2Chamber" runat="server" OverrideHeight="90" /> </asp:Content> My banner1.ascx page has:<%@ Control Language="VB" ClassName="UserControl297" %> <%@ register tagprefix="uc1&

Problem with Asp:menu control in IE8

Hai friends, Here i am facing a new problem,i created a navigation page by using asp:menu control,and after when i viewed it in Internet explorer8, the SubMenu's are not displaying. But when i checked the Compatibility view button which is next ot Stop and Refresh Or in Tools->CompatabilityView. then it is displaying the submenus. The same problem exists in Google Chrome but not in FireFox Can any one tell me the solution how to view the submenus without changing the Compatability settings. Thanks Maniraju

Dynamic Columns Using Report Viewer Control

Hi,, I'm using Report viewer Control to generate reports.Currently i have static columns..I need to have columns created  based on the DB Query  results i.e., DB query will return more columns under certain conditions and less columns in another...In Short,Headers and column data will be known only at runtime.how can i bind the data dynamically...what can i do to accomplish this..

ASP.NET menu control with CSS Friendly dll casuses slow rendring

I am using ASP.NET menu control  with CSS Friendly dll casuses slow rendring,Is there any way i can make little bit fast rendring?Thanks in advance
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend