.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 repopulate after pageload

Posted By:      Posted Date: September 29, 2010    Points: 0   Category :ASP.Net
i have a dynamic generated menu that populate menu in the panel during page load, however, during postback, it regenerate menu again that makes it appear twice in panel.
 For this reason, i try to remove menu from panel01 and regenerate again, but unsuccessful. 
 protected void Page_Load(object sender, EventArgs e)




void PopulateMenu()





View Complete Post

More Related Resource Links

Dynamic Menu repopulate after postback.

found that the dynamic menu being repopulate after each postback and making it a duplicated menu in masterpage.
try to resolve so it could only generate once.
tried placing in a usercontrol and place 'PopulateMenu' in the Page_Init since masterpage does not have Page_PreInit event, but the menu does not load up. 
 if (!Page.IsPostBack)



        if (Page.IsPostBack)



void PopulateMenu()
        #region Menu Generate

        menu = null;

        if (Session["smenu"] != null)



          Session["smenu"] = menu;



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.


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()) %>'

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 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. 

Dynamic menu item in MenuItemTemplate (in SPGridView)




I am implementing a SPGridView in a webpart and would like to have dynamic row menus (with different menu items) based on some cell values. It seems that the answer is in the very-poorly documented property HiddenScript of a MenuItemTemplate object, which contains a custom javascript function which should return true if the menu item should be hidden, or false otherwise.


My question is - how do I pass arguments to this custom javascript function? This is how the sample code looks like:


SPMenuField colMenu = new SPMenuField();

colMenu.HeaderText = "Address";

colMenu.TextFields = "url";

colMenu.MenuTemplateId = "PresenterListMenu";

colMenu.NavigateUrlFields = "url";

colMenu.NavigateUrlFormat = "{0}";

Dynamically Generated Dynamic Menu Items Width Question


I have the following Menu:

<asp:Menu ID="MainMenu" runat="server" Orientation="Horizontal" 
	DynamicVerticalOffset="2" DynamicHorizontalOffset="2" 
	StaticEnableDefaultPopOutImage="false" DynamicEnableDefaultPopOutImage="false" >
        <StaticMenuItemStyle BackColor="#0099cc" ForeColor="#eeeeee" Font-Names="Arial" Font-Size="11" Height="18" HorizontalPadding="10" VerticalPadding="3"  />
	<StaticHoverStyle BackColor="#336699" ForeColor="#ffffff" Font-Names="Arial" Font-Size="11" />
	<DynamicMenuItemStyle BackColor="#0099cc" ForeColor="#eeeeee" Font-Names="Arial" Font-Size="10" Height="18" 
		HorizontalPadding="10" VerticalPadding="3" />
	<DynamicHoverStyle BackColor="#336699" ForeColor="#ffffff" Font-Names="Arial" Font-Size="10" />					
		<asp:MenuItemBinding DataMember="Item" TextField="Title" />
		<asp:MenuItemBinding DataMember="SubItem" TextField="Title" />						

I am unable to create dynamic menu from database


Hi Expert,

I am unable to create dynamic menu from database. I have made two tables for this work.

First table is Menu which stores menu id and its relevant name.
MId Text
1 File
2 Edit
3 View

Second table is subMenu which stores submenus which will be linked to the menu table with menu id.

SId Text MID
1 New 1
2 Open 1
3 Save 1
4 Cut 2
5 Copy 2

the menu should be created dynamically from the database, each menu should be displayed in single row

when we click on a menu the submenus are displayed in rows that in expand & contrast form

how to design & develope this page

Creating dynamic category menu integrate with back office.


Dear friends,

Im developing ecommerce website and i want to add category menu to my website. This category menu should have 2 levels for sub categories as well. I tried navigation controls in ASP.net. But still i cant understand how to create the navigation menu in order to integrate with back office. I understand that i can do this with XML file, But if i want to add new products categories or remove categories, XML file should update automatically according to that. I don't understand how to do that. In brief all i want is create category menu with subcategories and i want to control this from my back office.

i read this tutorial http://www.asp.net/web-forms/tutorials/tailspin-spyworks-part-3  But it doesnt shows subcategory menus.

Im new to asp.net. so please explain me what is the simplest way to create such menu,

WPF Dynamic menu associated with the object?


Hi everyone. I'd like to be able to create dynamic menus associated with certain object. Let’s say, I will have 3 listview container with one style where I also have a Menu. I need to generate different menu items from collection of the RoutetUICommands in relation on each listview. I was trying to solve this puzzle but took me a while and still have trouble making it work. Any ideas are highly appreciated. Thank you!



Dynamic Sub Menu Item Command Not working in WPF...MVVM

<MenuItem Header="Flag(s)" ItemsSource="{Binding Path=LineItemFlags}" >
                                <Style TargetType="{x:Type MenuItem}">

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

latest dynamic menu in WPF


Hi all,

            i want get some idea to create dynamic menu for my application. although i have seen sample from codeproject but i want some latest idea.


Thank's in advance.

atik sarker

Dynamic menu help


Hey guys, i'm learning working with MVC, and i'm builiding a small test applications witch has a simple menu, loaded form a database.

I've made the method to query the database and returns the menu data (ID, Title, Action, Controller).


The ideia is to add this loaded menu to the _Layout.cshtml, so its allways be available.


Fist i've created the ActionResult


public class MenuItemsController : Controller

 public PartialViewResult menuItems()
            var item = new Models.MenuItemRepository();
            var data = item.list();
            return PartialView(data);



Then i've rendered the partial view in the Layout


    <div class="page">
            <div id="title">
                <h1>My MVC Application</h1>
            <div id="logindisplay">
                @Html.Partial("_menuItems", );

in the View i have

@model IEnumerable<mvcAppz.Models.

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.

Dynamic Data Templates in GridView ASP.NET 3.5

At a high level, Dynamic Data Templates can be seen as a system to very quickly build up a User Interface linked with the relevant data model, immediately enabling you to perform CRUD operations (Create, Read, Update, Delete) on the database using the specified data source. They provide a powerful method for building up these kinds of applications, and I'm going to focus on an overview of what Dynamic Data Templates actually are, and a few ways of customizing them to suit industry needs.

ASP.NET Menu with jQuery Superfish

Choosing the right type of menu for a website is not easy at all. The ASP.NET Menu Control is definitely NOT a good starting point due to the horrendous markup it renders, nor is it good for SEO because of the Markup/Content ratio, neither can it be easily styled.
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