How can i create menu bar in asp.net particularly in asp.net1.1(.net framework2003)

Dani AI

Generated

For context: Visual Studio .NET 2003 (ASP.NET 1.1) does not include the newer server-side Menu control that arrived in ASP.NET 2.0. The usual patterns for that platform are a small client-side JavaScript/CSS menu for static navigation, or server-side generation (a UserControl or literal output) when items come from a database. This ties back to ’s JavaScript suggestion and ’s note about database-driven menus for dynamic sites; below are practical, concrete steps and a short server-side example.

A simple, robust approach for the “File → New / Open / Save” style menu is to emit semantic HTML (nested ul / li with anchors) and enhance it with CSS for visuals and a tiny script to toggle visibility or handle keyboard focus. That gives graceful degradation if JS is disabled, and keeps markup accessible. For dynamic sites, render the same nested ul structure on the server so the page works without client scripting.

Example server-side pattern (C#): store menu rows with Id, ParentId, Title, Url, SortOrder; load into a DataTable and recursively build nested <ul> blocks. Render into a Literal on the page.

private void BuildMenuHtml(int parentId, DataTable dt, StringBuilder sb)
{
    DataRow[] rows = dt.Select("ParentId=" + parentId, "SortOrder ASC");
    if (rows.Length == 0) return;
    sb.Append("<ul>");
    foreach (DataRow r in rows)
    {
        string url = HttpUtility.HtmlEncode(r["Url"].ToString());
        string title = HttpUtility.HtmlEncode(r["Title"].ToString());
        sb.AppendFormat("<li><a href=\"{0}\">{1}</a>", url, title);
        BuildMenuHtml(Convert.ToInt32(r["Id"]), dt, sb);
        sb.Append("</li>");
    }
    sb.Append("</ul>");
}

Practical tips: cache the generated HTML for performance; always HTML-encode titles/URLs to prevent XSS; test in old IE for z-index/positioning quirks; add basic keyboard support for accessibility; keep markup simple so later framework upgrades (to use built-in Menu/SiteMap controls) are easier. This approach provides a clear path from the static example given by to a scalable, database-driven menu.

Recommended Answers

All 5 Replies

you must create a javascript menu, or you can download some suitable ones from free javascript resource websites. try the ones in dynamicdrive.com. If you want to populate the menu content from the database, i can help you with the details, for a simple static content menu refer to my blog entry http://www.daniweb.com/blogs/entry2065.html

Thanks for replying my friend serkansendur, This umapathyperumal...

problem in creating menu bar in asp.net2003
What i am asking is? Inorder to create menubar in the web form of Asp.Net2003(Through by java script)

For Example: Menu Bar should be like this

File
New
Open
Save

What is the coding for this?

Thanks for replying my friend serkansendur, This umapathyperumal...
problem in creating menu bar in asp.net2003
What i am asking is? Inorder to create menubar in the web form of Asp.Net2003(Through by java script)
For Example: Menu Bar should be like this
File
New
Open
Save
What is the coding for this?

Hi umapathyperumal,
Few days ago i also wanted to develop menu for my website, during this i came across the dynamic menu which is generated from Database. Following is the link, please visit that link.

http://aspalliance.com/822

Hope this will help also you can customize according to your need.
Thanks & Regards
Dilip Kumar Vishwakarma
Programmer
.Net Consulting

Thanks for replying my friend serkansendur, This umapathyperumal...
problem in creating menu bar in asp.net2003
What i am asking is? Inorder to create menubar in the web form of Asp.Net2003(Through by java script)
For Example: Menu Bar should be like this
File
New
Open
Save
What is the coding for this?

Hi umapathyperumal,
Few days ago i also wanted to develop menu for my website, during this i came across the dynamic menu which is generated from Database. Following is the link, please visit that link.

http://aspalliance.com/822

Hope this will help also you can customize according to your need.
Thanks & Regards
Dilip Kumar Vishwakarma
Programmer
.Net Consulting

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.