asp menubar question

Discussion in 'ASP General' started by Raphael Gluck, Aug 2, 2004.

  1. Hi

    I am wondering if anyone can help me

    I am trying to build a menu bar navigation for my site, and would like the
    contents of the menu bar to be linked to a database.
    E.G If I have ten initial product Categories, in my main database table, I
    want to link it to a menubar to display the main categories on the front
    page of my site.

    Does anyone know of a script that I could modify?
    I've searched quite a bit, for an ASP driven menu bar, and other phrases
    too, but I have not found anything yet.

    I hope someone can help

    Raphael
     
    Raphael Gluck, Aug 2, 2004
    #1
    1. Advertising

  2. There's no magic here... it's just HTML you're creating. So, figure out
    what the HTML that you want the menu to look like, and then just build it
    from a query. For example, if you wanted it to look like this:

    <table>
    <tr>
    <td><a href=breakdown.asp?cat=1>Category 1</a></td>
    <td><a href=breakdown.asp?cat=2>Category 2</a></td>
    </tr>
    </table>

    Then from ASP you would do this:

    <%
    set conn = CreateObject("ADODB.Connection")
    conn.open "<connection string>"
    sql = "SELECT CategoryID, Description " & _
    "FROM Categories ORDER BY CategoryID"
    response.write "<table><tr>"
    set rs = conn.execute(sql)
    do while not rs.eof
    response.write "<td><a href=breakdown.asp?cat="
    response.write rs(0) & ">" & rs(1) & "</a></td>"
    rs.movenext
    loop
    response.write "</tr></table>"
    rs.close: set rs = nothing: conn.close: set conn = nothing
    %>

    --
    http://www.aspfaq.com/
    (Reverse address to reply.)




    "Raphael Gluck" <> wrote in message
    news:#...
    > Hi
    >
    > I am wondering if anyone can help me
    >
    > I am trying to build a menu bar navigation for my site, and would like the
    > contents of the menu bar to be linked to a database.
    > E.G If I have ten initial product Categories, in my main database table, I
    > want to link it to a menubar to display the main categories on the front
    > page of my site.
    >
    > Does anyone know of a script that I could modify?
    > I've searched quite a bit, for an ASP driven menu bar, and other phrases
    > too, but I have not found anything yet.
    >
    > I hope someone can help
    >
    > Raphael
    >
    >
     
    Aaron [SQL Server MVP], Aug 2, 2004
    #2
    1. Advertising

  3. Raphael Gluck

    Steven Burn Guest

    '// Page name: dbfunctions.asp

    '// Replace the_database.mdb with the filename of your database
    '//
    '// Assumes: database is in the same folder as these files
    Const objDB = "the_Database.mdb"

    Function ConnectToDB(dbPath)
    '// The code you use to connect to your database goes here
    Set DB = Server.Createobject("ADODB.Connection")
    DB.Mode = adModeReadWrite
    DB.Open ("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" +
    Server.MapPath(dbPath))
    Set ConnectToDB = DB
    End Function

    '// END dbfunctions.asp

    '// Page name: menu.asp

    <%
    Set DB = ConnectToDB(objDB)
    Set rst = Server.Createobject("ADODB.Recordset")
    rst.Open "Select Menu from tblMenu Order By MENU ASC", db, adOpenStatic,
    adLockReadOnly
    Do While Not rst.eof
    %>
    <a href="default.asp?menu=<%=rst("Menu")%>"><%=rst("Menu")%></a><br>
    <%
    rst.Movenext
    Loop
    %>

    '// END menu.asp

    '// Page name: default.asp
    <!--#include file="dbfunctions.asp"-->
    <!--#include file="menu.asp"-->
    <%
    strMenu = request.querystring("menu")
    Select Case lcase(strMenu)
    Case ""
    '// Your homepage
    Case "home"
    '// Do something
    Case Else
    '// Do something
    End Select
    %>
    '// END default.asp

    --

    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!


    "Raphael Gluck" <> wrote in message
    news:#...
    > Hi
    >
    > I am wondering if anyone can help me
    >
    > I am trying to build a menu bar navigation for my site, and would like the
    > contents of the menu bar to be linked to a database.
    > E.G If I have ten initial product Categories, in my main database table, I
    > want to link it to a menubar to display the main categories on the front
    > page of my site.
    >
    > Does anyone know of a script that I could modify?
    > I've searched quite a bit, for an ASP driven menu bar, and other phrases
    > too, but I have not found anything yet.
    >
    > I hope someone can help
    >
    > Raphael
    >
    >
     
    Steven Burn, Aug 2, 2004
    #3
  4. Thanks you Aaron

    I forgot to acknowledge your help, so thanks.

    I'll have a try

    "Aaron [SQL Server MVP]" <> wrote in message
    news:%...
    > There's no magic here... it's just HTML you're creating. So, figure out
    > what the HTML that you want the menu to look like, and then just build it
    > from a query. For example, if you wanted it to look like this:
    >
    > <table>
    > <tr>
    > <td><a href=breakdown.asp?cat=1>Category 1</a></td>
    > <td><a href=breakdown.asp?cat=2>Category 2</a></td>
    > </tr>
    > </table>
    >
    > Then from ASP you would do this:
    >
    > <%
    > set conn = CreateObject("ADODB.Connection")
    > conn.open "<connection string>"
    > sql = "SELECT CategoryID, Description " & _
    > "FROM Categories ORDER BY CategoryID"
    > response.write "<table><tr>"
    > set rs = conn.execute(sql)
    > do while not rs.eof
    > response.write "<td><a href=breakdown.asp?cat="
    > response.write rs(0) & ">" & rs(1) & "</a></td>"
    > rs.movenext
    > loop
    > response.write "</tr></table>"
    > rs.close: set rs = nothing: conn.close: set conn = nothing
    > %>
    >
    > --
    > http://www.aspfaq.com/
    > (Reverse address to reply.)
    >
    >
    >
    >
    > "Raphael Gluck" <> wrote in message
    > news:#...
    > > Hi
    > >
    > > I am wondering if anyone can help me
    > >
    > > I am trying to build a menu bar navigation for my site, and would like

    the
    > > contents of the menu bar to be linked to a database.
    > > E.G If I have ten initial product Categories, in my main database table,

    I
    > > want to link it to a menubar to display the main categories on the front
    > > page of my site.
    > >
    > > Does anyone know of a script that I could modify?
    > > I've searched quite a bit, for an ASP driven menu bar, and other phrases
    > > too, but I have not found anything yet.
    > >
    > > I hope someone can help
    > >
    > > Raphael
    > >
    > >

    >
    >
     
    Raphael Gluck, Aug 4, 2004
    #4
  5. Thank you Steve for that

    Apologies for the delay in acknowledgement.
    "Steven Burn" <> wrote in message
    news:...
    > '// Page name: dbfunctions.asp
    >
    > '// Replace the_database.mdb with the filename of your database
    > '//
    > '// Assumes: database is in the same folder as these files
    > Const objDB = "the_Database.mdb"
    >
    > Function ConnectToDB(dbPath)
    > '// The code you use to connect to your database goes here
    > Set DB = Server.Createobject("ADODB.Connection")
    > DB.Mode = adModeReadWrite
    > DB.Open ("PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" +
    > Server.MapPath(dbPath))
    > Set ConnectToDB = DB
    > End Function
    >
    > '// END dbfunctions.asp
    >
    > '// Page name: menu.asp
    >
    > <%
    > Set DB = ConnectToDB(objDB)
    > Set rst = Server.Createobject("ADODB.Recordset")
    > rst.Open "Select Menu from tblMenu Order By MENU ASC", db,

    adOpenStatic,
    > adLockReadOnly
    > Do While Not rst.eof
    > %>
    > <a href="default.asp?menu=<%=rst("Menu")%>"><%=rst("Menu")%></a><br>
    > <%
    > rst.Movenext
    > Loop
    > %>
    >
    > '// END menu.asp
    >
    > '// Page name: default.asp
    > <!--#include file="dbfunctions.asp"-->
    > <!--#include file="menu.asp"-->
    > <%
    > strMenu = request.querystring("menu")
    > Select Case lcase(strMenu)
    > Case ""
    > '// Your homepage
    > Case "home"
    > '// Do something
    > Case Else
    > '// Do something
    > End Select
    > %>
    > '// END default.asp
    >
    > --
    >
    > Regards
    >
    > Steven Burn
    > Ur I.T. Mate Group
    > www.it-mate.co.uk
    >
    > Keeping it FREE!
    >
    >
    > "Raphael Gluck" <> wrote in message
    > news:#...
    > > Hi
    > >
    > > I am wondering if anyone can help me
    > >
    > > I am trying to build a menu bar navigation for my site, and would like

    the
    > > contents of the menu bar to be linked to a database.
    > > E.G If I have ten initial product Categories, in my main database table,

    I
    > > want to link it to a menubar to display the main categories on the front
    > > page of my site.
    > >
    > > Does anyone know of a script that I could modify?
    > > I've searched quite a bit, for an ASP driven menu bar, and other phrases
    > > too, but I have not found anything yet.
    > >
    > > I hope someone can help
    > >
    > > Raphael
    > >
    > >

    >
    >
     
    Raphael Gluck, Aug 4, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jho
    Replies:
    8
    Views:
    7,182
  2. edgarjang

    How can I use "menubar=no"

    edgarjang, Jan 29, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    9,488
    Do Quyet Tien
    Jan 29, 2004
  3. RJDev

    Manipulate Menubar and Toolbar

    RJDev, Jun 23, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    336
    avnrao
    Jun 23, 2004
  4. =?Utf-8?B?bWF2cmljazEwMQ==?=

    ASP.NET FORM to new Window '_new' but how to hide menubar, toolbar

    =?Utf-8?B?bWF2cmljazEwMQ==?=, Apr 7, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    3,907
    Brock Allen
    Apr 7, 2005
  5. Replies:
    4
    Views:
    366
    Chris Fulstow
    Oct 12, 2006
Loading...

Share This Page