User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 426,174 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 1,868 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 22553 | Replies: 7 | Solved
Reply
Join Date: Mar 2004
Location: Brisbane
Posts: 632
Reputation: Slade has a spectacular aura about Slade has a spectacular aura about 
Rep Power: 7
Solved Threads: 6
Slade's Avatar
Slade Slade is offline Offline
Practically a Master Poster

Drop Down Menu

  #1  
Jun 29th, 2004
Hi, I need to know how I would go about making a drop down menu in asp .net using vb .net...

Thanks,

Slade
Formerly known as Slade.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2003
Location: Canada
Posts: 786
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Rep Power: 9
Solved Threads: 25
Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Solution Re: Drop Down Menu

  #2  
Jul 3rd, 2004
Originally Posted by slade
Hi, I need to know how I would go about making a drop down menu in asp .net using vb .net...

Thanks,

Slade

Hope this helps dude!

//**************************************
    // Name: Menu pagelet for ASP.NET
    // Description:Simple server-side menu control - kind of - for ASP.NET pages. It's best suited for a site where all pages use the same menu. All pages share the same pagelet, which contains all the menu items and the logic. You can define two menu levels (main menu and submenus). When you click on a main menu item the submenu drops down. The currently shown page is shown bold in the menu.
    The code contains the pagelet (navbar.ascx) and a sample page using it.
    // By: Klemens Schmid (old)
    //
    //
    // Inputs:None
    //
    // Returns:None
    //
    //Assumes:The code uses VB.NET syntax but almost no dotnet features. You could adapt the code to work under plain ASP as well. The pagelet would become an include then. However, this is less elegant then using pagelets in ASP.NET.
    You can see the code in action at www.klemid.de/aspmenu.aspx. 
    Maybe you need my styles.css to make it look good.
    //
    //Side Effects:None
    //This code is copyrighted and has limited warranties.
    //Please see http://www.Planet-Source-Code.com/xq...s/ShowCode.htm
    //for details.
    //**************************************
    
    --------------------------------------------------
    Pagelet code: 
    --------------------------------------------------
    <!-- navigation bar for klemid's web 
    <script language="VB" runat="server">
    Dim MenuEntry(,) As object = { _
    {"Home", "welcome.aspx", "", true}, _
    {"Interests", "interests.aspx", "", true}, _
    {"My Tools", "tools.aspx", "", true}, _
    {"ASP.NET Menu", "aspmenu.aspx", "My Tools", false}, _
    {"SMS via http", "vbsms.aspx", "My Tools", false}, _
    {"OL2WAP", "ol2wap.aspx", "My Tools", false}, _
    {"Form Sniffer", "formsniffer2.aspx", "My Tools", false}, _
    {"Crypt File", "cryptfile.aspx", "My Tools", false}, _
    {"Copy Contacts", "copycontacts.aspx", "My Tools", false}, _
    {"eBay Reminder", "ebayrem.aspx", "My Tools", false}, _
    {"Fav2Web", "fav2web.aspx", "My Tools", false}, _
    {"Lex4VB", "lex4vb.aspx", "My Tools", false}, _
    {"M-Pad", "mpad.asp", "", true}, _
    {"My Charts", "mycharts.aspx", "", true}, _
    {"Select", "mycharts1.aspx", "My Charts", false}, _
    {"Display", "mycharts2.aspx", "My Charts", false}, _
    {"Urlaub", "urlaub.aspx", "", true}, _
    {"Ruhpolding", "ruhpolding.aspx", "Urlaub", false}, _
    {"Wiesloch", "wiesloch.aspx", "", true}, _
    {"Top 30 WapMarks", "topwap.aspx", "", true}, _
    {"Top 30 WebMarks", "topweb.aspx", "", true}, _
    {"All My WebMarks", "allweb.aspx", "", true}, _
    {"", "", "", true}, _
    {"Email", "mailto:feedback@schmidks.de?subject=Feedback", "", true}, _
    {"Disclaimer", "http://www.disclaimer.de/disclaimer.htm", "", true} _
    }
    Dim i as integer
    Dim strCurrentPage as String 
    dim bSubmenuStarting as Boolean = false
    
    Sub Page_Load(Source as Object, E as EventArgs)
    Dim i, j as Integer
    Dim strParent as String
    
    'switch on the submenu according to the currently displayed page
    strCurrentPage = Request.Url.Segments.GetValue(Request.Url.Segments.GetUpperBound(0))
    For i=0 To MenuEntry.GetUpperBound(0)
    If MenuEntry(i, 1) = strCurrentPage Then
    If MenuEntry(i, 2) = "" Then
    'main menu item was clicked
    strParent = MenuEntry(i, 0)
    Else
    'submenu item was clicked
    strParent = MenuEntry(i,2)
    End If
    'found -> switch on the 'visible' flag for submenu items
    For j=0 To MenuEntry.GetUpperBound(0)
    If MenuEntry(j, 2) = strParent Then
    MenuEntry(j, 3) = True
    End If
    Next
    Exit For
    End If
    Next
    End Sub
    </script>
    -->
    <table cellspacing="1" cellpadding="3" bgcolor="white" align=center>
    <% for i=0 to MenuEntry.GetUpperBound(0) %>
    <% if MenuEntry(i,0) = "" Then 'separator line%>
    <tr>
    <td bgcolor="#dedebe" height="1">
    </tr>
    <tr>
    <td bgcolor="#dedebe" height="1">
    </tr>
    <% else 'normal link %>
    <% if i > 0 AndAlso MenuEntry(i-1, 2) <> "" AndAlso MenuEntry(i, 2) = "" AndAlso MenuEntry(i-1, 3) Then 'submenu ends %>
    </table>
    <% end if %>
    <% bSubmenuStarting = (i > 0 AndAlso MenuEntry(i, 2) <> "" AndAlso MenuEntry(i, 3) AndAlso MenuEntry(i+1, 2) = "") %>
    <% if bSubmenuStarting Then %>
    <td bgcolor="#f2f2e6" >
    <table border="0" cellspacing="0" bgcolor="#ececd9">
    <% end if %>
    <% if MenuEntry(i, 2) <> "" Then 'submenu entry %>
    <% if MenuEntry(i, 3) Then %>
    <tr>
    <td width="100%" bgcolor="#f2f2e6" <%= IIf(MenuEntry(i,1)=strCurrentPage, "style=""FONT-WEIGHT: bold""", "") %> >
    <font size="2"><nobr>
    <a href="<%= MenuEntry(i,1) %>" class="NavLink"><%= MenuEntry(i,0)%></a>
    </nobr></font>
    </td>
    </tr>
    <% End if%>
    <% else 'main menu %>
    <tr>
    <td bgcolor="#dedebe" height="18" <%= IIf(MenuEntry(i,1)=strCurrentPage, "style=""FONT-WEIGHT: bold""", "") %> >
    <nobr>
    <a href="<%= MenuEntry(i,1) %>" class="NavLink"><%= MenuEntry(i,0)%></a>
    </nobr>
    </td>
    </tr>
    <% end if %>
    <% end if %>
    <% next %>
    </table>
    --------------------------------------------------
    Sample page
    --------------------------------------------------
    <%@ Register TagPrefix="klemid" TagName="NavBar" Src="navbar.ascx" %>
    <%@ Page Language="vb" AutoEventWireup="true" Debug="true" %>
    <%@ Import namespace="System.IO" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <title>ASP.NET Menu</title>
    <meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
    <meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <meta http-equiv="Content-Language" content="en-us">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    <LINK href="Styles.css" type="text/css" rel="stylesheet">
    <script id="fill" runat="server">
    Sub Page_Load(sender as object, e as System.EventArgs) 
    Dim SReadToEnd As Stream
    'read the pagelet
    SReadToEnd = File.OpenRead(Page.MapPath(".\navbar.ascx"))
    Dim SrReadToEnd As StreamReader = New StreamReader(SReadToEnd, _
    System.Text.Encoding.ASCII)
    'SrReadToEnd.BaseStream.Seek(0, SeekOrigin.Begin)
    txtPagelet.Text = SrReadToEnd.ReadToEnd()
    SrReadToEnd.Close()
    'read this page
    SReadToEnd = File.OpenRead(Page.MapPath(Page.Request.FilePath()))
    SrReadToEnd = New StreamReader(SReadToEnd, System.Text.Encoding.ASCII)
    'SrReadToEnd.BaseStream.Seek(0, SeekOrigin.Begin)
    txtThisPage.Text = SrReadToEnd.ReadToEnd()
    SrReadToEnd.Close()
    End Sub
    </script>
    </HEAD>
    <body style="BACKGROUND-IMAGE: none" leftMargin="0" topMargin="0" marginheight="0" marginwidth="0">
    <table dir="ltr" height="100%" cellSpacing="0" cellPadding="10" width="100%" border="0">
    <tr>
    <td vAlign="top" bgColor="#cccc99">
    <!-- header --><klemid:navbar id="NavBar" runat="server"></klemid:navbar></td>
    <td vAlign="top" width="100%">
    <!-- actual body goes here --><a name="Oben"></a>
    <h2 align="center">ASP.NET Menu</h2>
    <p>
    <p style="MARGIN-TOP: 10px; MARGIN-BOTTOM: 5px" align="center">
    Inspect the source code of the menu seen on the left side
    <P>
    <P>
    <hr>
    See how the menu on the left side of my pages is implemented. It is done by an 
    ASP.NET pagelet. Of course, you can buy a full-blown ASP.NET menu control like 
    the ones found at <A href="http://www.asp.net">www.asp.net</A>
    , but those are not free and they are mostly overkill for a small web site 
    having only one menu.
    <P></P>
    <P>Although the code here works only for ASP.NET it would be an easy exercise the 
    adapt it for pure ASP.
    </P>
    <form runat="server">
    <P></P>
    <P>Pagelet code (navbar.ascx):</P>
    <P>
    <asp:TextBox id="txtPagelet" runat="server" Width="100%" Height="114px" TextMode="MultiLine" ReadOnly="True"></asp:TextBox></P>
    <P>This page's code:</P>
    <p></p>
    <asp:TextBox id="txtThisPage" runat="server" Width="100%" Height="114px" TextMode="MultiLine" DESIGNTIMEDRAGDROP="282" ReadOnly="True"></asp:TextBox>
    <P></P>
    <P> </P>
    </form>
    </td>
    </tr>
    </table>
    </body>
    </HTML>


Now this is not really a drop down menu, but it is a Side Panel Menu similar to MS Access Database window or the side panel menu's in Windows XP.

I am sure I have source code at home to do exactly what you want, but I could be wrong. It may be source code to do it in JavaScript!

Later
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
Reply With Quote  
Join Date: Feb 2002
Location: New York
Posts: 862
Reputation: Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light 
Rep Power: 12
Solved Threads: 15
Moderator
Tekmaven's Avatar
Tekmaven Tekmaven is offline Offline
The C# Man, Myth, Legend

Re: Drop Down Menu

  #3  
Jul 3rd, 2004
A better solution would be skmMenu, an open-source ASP.NET based menu application.
-Ryan Hoffman

ASP.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
Reply With Quote  
Join Date: Mar 2004
Location: Brisbane
Posts: 632
Reputation: Slade has a spectacular aura about Slade has a spectacular aura about 
Rep Power: 7
Solved Threads: 6
Slade's Avatar
Slade Slade is offline Offline
Practically a Master Poster

Re: Drop Down Menu

  #4  
Jul 4th, 2004
Thanks very much tekmaven! That was VERY helpful!
Formerly known as Slade.
Reply With Quote  
Join Date: Feb 2002
Location: New York
Posts: 862
Reputation: Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light 
Rep Power: 12
Solved Threads: 15
Moderator
Tekmaven's Avatar
Tekmaven Tekmaven is offline Offline
The C# Man, Myth, Legend

Re: Drop Down Menu

  #5  
Jul 5th, 2004
Just doing what Dani forces me to ;-).
-Ryan Hoffman

ASP.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
Reply With Quote  
Join Date: Feb 2003
Location: Canada
Posts: 786
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Rep Power: 9
Solved Threads: 25
Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Re: Drop Down Menu

  #6  
Jul 5th, 2004
Forces.....Forces...hmmm, why do I find that hard to believe? Although Dani being forceful does have some interesting connotations to it.
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
Reply With Quote  
Join Date: Feb 2002
Location: New York
Posts: 862
Reputation: Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light Tekmaven is a glorious beacon of light 
Rep Power: 12
Solved Threads: 15
Moderator
Tekmaven's Avatar
Tekmaven Tekmaven is offline Offline
The C# Man, Myth, Legend

Re: Drop Down Menu

  #7  
Jul 5th, 2004
Originally Posted by Paladine
Forces.....Forces...hmmm, why do I find that hard to believe? Although Dani being forceful does have some interesting connotations to it.

Well, heh ;-). This thread had my first post that I didn't type from Dani's house in about three weeks. She doesn't force me at gunpoint, but, she begs in a cute way, and ya just can't say no . LOL
-Ryan Hoffman

ASP.NET Specialist / Webmaster, Extended64.com.
Please do not email or PM me with support questions. Please direct them to the forums instead.
Reply With Quote  
Join Date: Feb 2003
Location: Canada
Posts: 786
Reputation: Paladine has a spectacular aura about Paladine has a spectacular aura about Paladine has a spectacular aura about 
Rep Power: 9
Solved Threads: 25
Colleague
Paladine's Avatar
Paladine Paladine is offline Offline
Master Poster

Solution Re: Drop Down Menu

  #8  
Jul 5th, 2004


Hahaha.. LOL I had figured she had that way about her, that certain irresistable charm to do as she asks. :lol: :cheesy:

And we appreciate her doing so, your assistance is of course appreciated as well!
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb ASP.NET Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the ASP.NET Forum

All times are GMT -4. The time now is 6:16 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC