Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > asp menubar question

Reply
Thread Tools

asp menubar question

 
 
Raphael Gluck
Guest
Posts: n/a
 
      08-02-2004
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


 
Reply With Quote
 
 
 
 
Aaron [SQL Server MVP]
Guest
Posts: n/a
 
      08-02-2004
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" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Steven Burn
Guest
Posts: n/a
 
      08-02-2004
'// 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("M enu")%></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" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Raphael Gluck
Guest
Posts: n/a
 
      08-04-2004
Thanks you Aaron

I forgot to acknowledge your help, so thanks.

I'll have a try

"Aaron [SQL Server MVP]" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
Raphael Gluck
Guest
Posts: n/a
 
      08-04-2004
Thank you Steve for that

Apologies for the delay in acknowledgement.
"Steven Burn" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> '// 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("M enu")%></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" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET2.0 controls and Menubar's compatibility with Mac IE Browser dreamamit2001@gmail.com ASP .Net 4 10-12-2006 02:20 PM
ASP.NET FORM to new Window '_new' but how to hide menubar, toolbar =?Utf-8?B?bWF2cmljazEwMQ==?= ASP .Net 1 04-07-2005 04:28 AM
How can I use "menubar=no" edgarjang ASP .Net 2 01-29-2004 03:33 AM
Change height of menubar and tabs? area51 Firefox 0 01-12-2004 06:15 AM
hiding browser toolbar and menubar Jho ASP .Net 8 12-31-2003 03:38 PM



Advertisments