473,320 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

how to build dynamic menu with submenus

I've got a problem with asp.net i am trying to make a menu control. and have
searched the web for serveral controls but they don't work correctly.

I am pretty new to asp.net building. What am i looking for. i am looking for
code to make a dynamical menu with submenus The menu items are stored in a MS
SQL Table and when by loading the page the items will be created. i have made
a asp table. i want my menu on the left cell, in the middle cell i want to
change my pages to the menu item choosen.

This is what my page look like right now
<form id="Form1" method="post" runat="server">
<asp:Table id="Table1" runat="server" Height="72px" Width="944px">
<asp:TableRow>
<asp:TableCell>
<asp:linkbutton id="btnLogOut" style="Z-INDEX: 102; LEFT: 8px; TOP:
8px" runat="server" Width="80px"
Height="8px">Logout</asp:linkbutton> </asp:TableCell>
<asp:TableCell>
<asp:textbox id="txtUsername" style="Z-INDEX: 101; LEFT: 112px; TOP:
8px" runat="server" Width="144px"
Height="24px"></asp:textbox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<uc1:Menu id="Menu1" runat="server"></uc1:Menu>
</asp:TableCell>
<asp:TableCell>
<uc1:messages id="Messages1" runat="server"></uc1:messages>
</asp:TableCell>
<asp:TableCell>test</asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
</body>

so for an instance i want to change the messages to Sent items page how can
i do that?
It would be great if some one can give me some examples of making menus and
how to change the page.
and is it possible to do it all from the code behind?
Nov 19 '05 #1
4 3968
You have already posted this question once. You only need one posting,
especially as you posted it just two hours ago, in addition, I answered your
post but you didnt respond.

--
Best Regards

The Inimitable Mr Newbie º¿º

----------------------------
"paula" <pa***@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
I've got a problem with asp.net i am trying to make a menu control. and
have
searched the web for serveral controls but they don't work correctly.

I am pretty new to asp.net building. What am i looking for. i am looking
for
code to make a dynamical menu with submenus The menu items are stored in a
MS
SQL Table and when by loading the page the items will be created. i have
made
a asp table. i want my menu on the left cell, in the middle cell i want to
change my pages to the menu item choosen.

This is what my page look like right now
<form id="Form1" method="post" runat="server">
<asp:Table id="Table1" runat="server" Height="72px" Width="944px">
<asp:TableRow>
<asp:TableCell>
<asp:linkbutton id="btnLogOut" style="Z-INDEX: 102; LEFT: 8px; TOP:
8px" runat="server" Width="80px"
Height="8px">Logout</asp:linkbutton> </asp:TableCell>
<asp:TableCell>
<asp:textbox id="txtUsername" style="Z-INDEX: 101; LEFT: 112px; TOP:
8px" runat="server" Width="144px"
Height="24px"></asp:textbox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<uc1:Menu id="Menu1" runat="server"></uc1:Menu>
</asp:TableCell>
<asp:TableCell>
<uc1:messages id="Messages1" runat="server"></uc1:messages>
</asp:TableCell>
<asp:TableCell>test</asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
</body>

so for an instance i want to change the messages to Sent items page how
can
i do that?
It would be great if some one can give me some examples of making menus
and
how to change the page.
and is it possible to do it all from the code behind?

Nov 19 '05 #2
Not 100% sure I understand what you are asking, so let me give you some
general advice in the hopes that it might point you to the right place.

Controls can be dynamically created and added to your page. That is, you
could have something like this:

<tr id="MenuContainer" runat="server"
</tr>

and in your codebehind do:

for each row as DataRow in MyDataTableOfMenus
dim link as string = cstr(row("link"))
dim name as string = cstr(row("name"))
dim td as HtmlTableCell = CreateMenuItem(link, name)
MenuContainer.COntrols.Add(td)
next
function CreateMenuItem(link as string, name as string)
dim td as new HtmlTableCell
dim a as new HtmlAnchor
a.InnerText = name
a.HRef = link
td.Controls.Add(a)
return td
end function
You can do this with user control, built in server controls (shown above) or
your own custom server controls..

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/

"paula" <pa***@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
I've got a problem with asp.net i am trying to make a menu control. and
have
searched the web for serveral controls but they don't work correctly.

I am pretty new to asp.net building. What am i looking for. i am looking
for
code to make a dynamical menu with submenus The menu items are stored in a
MS
SQL Table and when by loading the page the items will be created. i have
made
a asp table. i want my menu on the left cell, in the middle cell i want to
change my pages to the menu item choosen.

This is what my page look like right now
<form id="Form1" method="post" runat="server">
<asp:Table id="Table1" runat="server" Height="72px" Width="944px">
<asp:TableRow>
<asp:TableCell>
<asp:linkbutton id="btnLogOut" style="Z-INDEX: 102; LEFT: 8px; TOP:
8px" runat="server" Width="80px"
Height="8px">Logout</asp:linkbutton> </asp:TableCell>
<asp:TableCell>
<asp:textbox id="txtUsername" style="Z-INDEX: 101; LEFT: 112px; TOP:
8px" runat="server" Width="144px"
Height="24px"></asp:textbox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<uc1:Menu id="Menu1" runat="server"></uc1:Menu>
</asp:TableCell>
<asp:TableCell>
<uc1:messages id="Messages1" runat="server"></uc1:messages>
</asp:TableCell>
<asp:TableCell>test</asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
</body>

so for an instance i want to change the messages to Sent items page how
can
i do that?
It would be great if some one can give me some examples of making menus
and
how to change the page.
and is it possible to do it all from the code behind?

Nov 19 '05 #3
Hi Karl it almost does but what do you do with sub menus?
how can you insert them in yoyr menu

kind regards

Paula

"Karl Seguin" wrote:
Not 100% sure I understand what you are asking, so let me give you some
general advice in the hopes that it might point you to the right place.

Controls can be dynamically created and added to your page. That is, you
could have something like this:

<tr id="MenuContainer" runat="server"
</tr>

and in your codebehind do:

for each row as DataRow in MyDataTableOfMenus
dim link as string = cstr(row("link"))
dim name as string = cstr(row("name"))
dim td as HtmlTableCell = CreateMenuItem(link, name)
MenuContainer.COntrols.Add(td)
next
function CreateMenuItem(link as string, name as string)
dim td as new HtmlTableCell
dim a as new HtmlAnchor
a.InnerText = name
a.HRef = link
td.Controls.Add(a)
return td
end function
You can do this with user control, built in server controls (shown above) or
your own custom server controls..

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/

"paula" <pa***@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
I've got a problem with asp.net i am trying to make a menu control. and
have
searched the web for serveral controls but they don't work correctly.

I am pretty new to asp.net building. What am i looking for. i am looking
for
code to make a dynamical menu with submenus The menu items are stored in a
MS
SQL Table and when by loading the page the items will be created. i have
made
a asp table. i want my menu on the left cell, in the middle cell i want to
change my pages to the menu item choosen.

This is what my page look like right now
<form id="Form1" method="post" runat="server">
<asp:Table id="Table1" runat="server" Height="72px" Width="944px">
<asp:TableRow>
<asp:TableCell>
<asp:linkbutton id="btnLogOut" style="Z-INDEX: 102; LEFT: 8px; TOP:
8px" runat="server" Width="80px"
Height="8px">Logout</asp:linkbutton> </asp:TableCell>
<asp:TableCell>
<asp:textbox id="txtUsername" style="Z-INDEX: 101; LEFT: 112px; TOP:
8px" runat="server" Width="144px"
Height="24px"></asp:textbox>
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<uc1:Menu id="Menu1" runat="server"></uc1:Menu>
</asp:TableCell>
<asp:TableCell>
<uc1:messages id="Messages1" runat="server"></uc1:messages>
</asp:TableCell>
<asp:TableCell>test</asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
</body>

so for an instance i want to change the messages to Sent items page how
can
i do that?
It would be great if some one can give me some examples of making menus
and
how to change the page.
and is it possible to do it all from the code behind?


Nov 19 '05 #4
Well, in that case you have your dynamically created Td, which you must add
a new table, row and then ur sub menus..in that sense it could be recursive,
say somethin glike:

for each row as DataRow in MyDataTableOfMenus
dim link as string = cstr(row("link"))
dim name as string = cstr(row("name"))
dim childRows as DataRow() = row.GetChildRows("SubItems")
CreateMenuItem(MenuContainer, link, name, childRows)
next
function CreateMenuItem(parentControl as control, link as string, name as
string, childRows as DataRow())
dim td as new HtmlTableCell
dim a as new HtmlAnchor
a.InnerText = name
a.HRef = link
td.Controls.Add(a)
parentControl.Controls.Add(td)
if childRows.Length > 0 then 'we have sub items to add
dim table as new HtmlTable()
dim tr as new HtmlTableRow()
table.Controls.Add(tr)
td.Controls.Add(table)
foreach row as DataRow in childRows
dim link as string = cstr(row("link"))
dim name as string = cstr(row("name"))
dim subRows as DataRow() = row.GetChildRows("SubItems")
CreateMenuItem(tr, link, name, subRows )
next
end function
The code is a lot more complex. I made some assumptions, for example, I
assumed that sub menu items were referenced using a relationship and thus
made use of GetChildRows...but whatever you do, you should be able to see
how I've simply created a new table and row, added them to my dynamically
created cell, and repeated the process ad nauseum

Cheers,
karl
--
MY ASP.Net tutorials
http://www.openmymind.net/

"paula" <pa***@discussions.microsoft.com> wrote in message
news:F2**********************************@microsof t.com...
Hi Karl it almost does but what do you do with sub menus?
how can you insert them in yoyr menu

kind regards

Paula

"Karl Seguin" wrote:
Not 100% sure I understand what you are asking, so let me give you some
general advice in the hopes that it might point you to the right place.

Controls can be dynamically created and added to your page. That is, you
could have something like this:

<tr id="MenuContainer" runat="server"
</tr>

and in your codebehind do:

for each row as DataRow in MyDataTableOfMenus
dim link as string = cstr(row("link"))
dim name as string = cstr(row("name"))
dim td as HtmlTableCell = CreateMenuItem(link, name)
MenuContainer.COntrols.Add(td)
next
function CreateMenuItem(link as string, name as string)
dim td as new HtmlTableCell
dim a as new HtmlAnchor
a.InnerText = name
a.HRef = link
td.Controls.Add(a)
return td
end function
You can do this with user control, built in server controls (shown above)
or
your own custom server controls..

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/

"paula" <pa***@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
> I've got a problem with asp.net i am trying to make a menu control. and
> have
> searched the web for serveral controls but they don't work correctly.
>
> I am pretty new to asp.net building. What am i looking for. i am
> looking
> for
> code to make a dynamical menu with submenus The menu items are stored
> in a
> MS
> SQL Table and when by loading the page the items will be created. i
> have
> made
> a asp table. i want my menu on the left cell, in the middle cell i want
> to
> change my pages to the menu item choosen.
>
> This is what my page look like right now
> <form id="Form1" method="post" runat="server">
> <asp:Table id="Table1" runat="server" Height="72px" Width="944px">
> <asp:TableRow>
> <asp:TableCell>
> <asp:linkbutton id="btnLogOut" style="Z-INDEX: 102; LEFT: 8px; TOP:
> 8px" runat="server" Width="80px"
> Height="8px">Logout</asp:linkbutton> </asp:TableCell>
> <asp:TableCell>
> <asp:textbox id="txtUsername" style="Z-INDEX: 101; LEFT: 112px; TOP:
> 8px" runat="server" Width="144px"
> Height="24px"></asp:textbox>
> </asp:TableCell>
> </asp:TableRow>
> <asp:TableRow>
> <asp:TableCell>
> <uc1:Menu id="Menu1" runat="server"></uc1:Menu>
> </asp:TableCell>
> <asp:TableCell>
> <uc1:messages id="Messages1" runat="server"></uc1:messages>
> </asp:TableCell>
> <asp:TableCell>test</asp:TableCell>
> </asp:TableRow>
> </asp:Table>
> </form>
> </body>
>
> so for an instance i want to change the messages to Sent items page how
> can
> i do that?
> It would be great if some one can give me some examples of making menus
> and
> how to change the page.
> and is it possible to do it all from the code behind?
>
>


Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Posting2002 | last post by:
Hi, I am trying to create the following: http://www.ece.uwaterloo.ca/~dbusuioc/site/menu_submenu.htm So far it's in Javascript and when you're going over the top buttons in the menu, it...
9
by: Chad Crowder | last post by:
I know this is a stupid question, but I'll be danged if I can't find it. I used to have a build and browse on the file menu when looking at aspx webforms (I know it didn't appear for the code...
3
by: ACaunter | last post by:
Hi there, can someone please tell me what the easiest way to have a dropdown menu bar positioned on the screen (eg. Home, company, ... , contact us) then when the mouse goes over then, the sub...
1
by: paulakeijzers | last post by:
I've got a problem with asp.net i am trying to make a menu control. and have searched the web for serveral controls but they don't work correctly. I am pretty new to asp.net building. What am i...
5
by: Jonathan | last post by:
Hello All, I am in the process of creating a 2/3 level collapsible/exspanible menu (called "nav") where users can click on a category and have the submenus appear beneath it and so on (allow...
1
by: awreese | last post by:
I've created a series of dropdown menus that work fine in Firefox, Safari, Camino, etc. but will not work at all in Windows IE. I'm presenting the whole file here hoping someone will come up with...
1
by: angelinahmaleka | last post by:
Hi all I am learning how to use submenus and I am struggling a bit. I am using the dynamic drive switch menu and I wish to make all menus close when another menu is selected. Currently this...
1
by: sydd | last post by:
Hi, I was wondering if it's possible to create a dynamic dropdown menu from this code. if($rs->getNumRows() > 0){ $intProjectCount = 1; $htmlOut ="<table width='100%' border='0'...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.