.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

Another Menu Control Question

Posted By:      Posted Date: May 22, 2011    Points: 0   Category :ASP.Net

protected void Page_Load(object sender, EventArgs e)
	System.Diagnostics.Debug.WriteLine("Page_Load IsPostBack: " + Page.IsPostBack.ToString());
	if (Page.IsPostBack)
		if(footermenu.SelectedValue != null) 
			System.Diagnostics.Debug.WriteLine("link: " + footermenu.SelectedValue);

protected void Page_Init(object sender, EventArgs e)
	System.Diagnostics.Debug.WriteLine("Page_Init IsPostBack: " + Page.IsPostBack.ToString());
	if (!Page.IsPostBack)
		Menus menu = new Menus();
		imgMainLogo.ImageUrl = VARIABLES.MainLogoImage;
		menu.PopulateMenuControl(ref mainmenu, 2);
		menu.PopulateMenuControl(ref footermenu, 9);

public void PopulateMenuControl(ref Menu menucontrol, int menuparentid)

	foreach (MenuFields mf in GetMenusByParentID(menuparentid))
		MenuItem menuitem = new MenuItem(mf.MenuName, ReplaceSystemNameLink(mf.Link));
		foreach (MenuFields cmf in GetMenusByParentID(mf.MenuID))
			MenuItem childmenuitem = new MenuItem(cmf.MenuName, ReplaceSystemNameLink(cmf.Link));

That's a sample code I have right now .. The menu items are populated dynamically at runtime as you can see. One of the menu items there has a link that goes off site.. my b

View Complete Post

More Related Resource Links

menu server control question


I got a menu server control where the "parent node display text" is A and the "child nodes" are B and C

when i put the mouse over the A, it will display the rest of the items (B and C) then if I select B, is it possible to change the top node to be B? (instead of originally A)



Dynamic menu control


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.


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.


output cache to be used only when parameter has changed + old question of user control not answered



i have 2 questions about output cache:

1.is it just me , or does it seems that it is used only after the second time that the user reaches the webpage? if so, why, and how can i tweak it to my needs? my guess is that it wouldn't be logical to cache every time a user reach a webpage, but only when it happens enough times.

2.i know that i can use "varybyparam" for using the output cache when the parameter doesn't change , but it seems that it would use the output cache even if there is no parameter , or if the specified paramter is not there. is there a way to overcome this?

3.an old question that somehow marked as "answered" , yet i didn't solve : suppose i created a user control and i gave it values through the CTOR via the aspx file . is it possible to show the values from within the split/design mode? remember that i've talking about ASP.NET and not simply C# winforms . i write this because this question was on :


and the answer that i got was for C# and winforms . i've tried to do the same for ASP.NET , but i've failed.

can anyone please help me?

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? 

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");

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 

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.

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

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

would like to put dealy on Menu control

I am using dhtml script from dyanamicdrive.com for Horizantal menu in web sites, On my menu link when I mouse over, I would like to put some delay before , it will show menu, can some one tell me how to do this?   thank you  

Login Control Question

I want to put a Login Control and a Create User Control on the same page.. just wondering, before I start am I going to run into any problems by doing this? 

Get Rid of Triangle Image on Menu Control

Does anyone know how to get rid of the Triangle that appears on the menu control? I didn't see any properties mentioned in the tree/menu control article by microsoft(http://msdn.microsoft.com/asp.net/whidbey/default.aspx?pull=/library/en-us/dnvs05/html/treeview.asp). I currently do not have the Beta installed so I don't have the library of docs to check for additional properties. I just want to use an image in the top menu items and want each image to be directly next to each other (Horizontal Configuration) but the Black triangle is getting in the way. Besides actually deleting the image from the server is there a way to do this? Thanks! VC

Navigate Menu asp Control Add Items (HOW?) c#


I feel like a complete idiot!! :)

I have a asp.net menu control on a default.aspx page

I want to add items to this menu control using the code behind file (C#)

How do I do this?

My menu id is mnuHeader

YES, newB question .. LOL


Thanks for your help in advance!!! 

Object Reference Error While Rendering Menu Control


I am having a problem with rendering a menu control inside a server control. I am getting an error in the RenderContents override method when I try to render the Menu Control. The error I am getting is an Object Reference error. The code is below...

[ToolboxData("<{0}:Login runat=server></{0}:Login>")]
    public class Login : CompositeControl
        #region Members

        Label tst;
        Menu loginMenu;
        MenuItem mainLoginItem;
        MenuItem loginItem;
        MenuItem usernameItem;
        MenuItem passwordItem;
        SubMenuStyle subMnuStyleControl;
        SubMenuStyle subMnuStyleMenu;

        bool isLoggedIn = false;


        #region Properties

        public bool IsLoggedIn
            get { return isLoggedIn; }

            set { isLoggedIn = value; }


        #region Overridden Events

        protected override void RenderContents(HtmlTextWriter writer)



        protected override void OnInit(EventArgs e)

            #region Add CSS references
            string cssUrl = Page.ClientScript.GetWebResourceUrl(this.Ge
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