473,714 Members | 2,552 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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:TableCel l>
<asp:linkbutt on id="btnLogOut" style="Z-INDEX: 102; LEFT: 8px; TOP:
8px" runat="server" Width="80px"
Height="8px">Lo gout</asp:linkbutton> </asp:TableCell>
<asp:TableCel l>
<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:TableCel l>
<uc1:Menu id="Menu1" runat="server"> </uc1:Menu>
</asp:TableCell>
<asp:TableCel l>
<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 3999
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***@discussi ons.microsoft.c om> wrote in message
news:FA******** *************** ***********@mic rosoft.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:TableCel l>
<asp:linkbutt on id="btnLogOut" style="Z-INDEX: 102; LEFT: 8px; TOP:
8px" runat="server" Width="80px"
Height="8px">Lo gout</asp:linkbutton> </asp:TableCell>
<asp:TableCel l>
<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:TableCel l>
<uc1:Menu id="Menu1" runat="server"> </uc1:Menu>
</asp:TableCell>
<asp:TableCel l>
<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="MenuContain er" runat="server"
</tr>

and in your codebehind do:

for each row as DataRow in MyDataTableOfMe nus
dim link as string = cstr(row("link" ))
dim name as string = cstr(row("name" ))
dim td as HtmlTableCell = CreateMenuItem( link, name)
MenuContainer.C Ontrols.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***@discussi ons.microsoft.c om> wrote in message
news:FA******** *************** ***********@mic rosoft.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:TableCel l>
<asp:linkbutt on id="btnLogOut" style="Z-INDEX: 102; LEFT: 8px; TOP:
8px" runat="server" Width="80px"
Height="8px">Lo gout</asp:linkbutton> </asp:TableCell>
<asp:TableCel l>
<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:TableCel l>
<uc1:Menu id="Menu1" runat="server"> </uc1:Menu>
</asp:TableCell>
<asp:TableCel l>
<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="MenuContain er" runat="server"
</tr>

and in your codebehind do:

for each row as DataRow in MyDataTableOfMe nus
dim link as string = cstr(row("link" ))
dim name as string = cstr(row("name" ))
dim td as HtmlTableCell = CreateMenuItem( link, name)
MenuContainer.C Ontrols.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***@discussi ons.microsoft.c om> wrote in message
news:FA******** *************** ***********@mic rosoft.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:TableCel l>
<asp:linkbutt on id="btnLogOut" style="Z-INDEX: 102; LEFT: 8px; TOP:
8px" runat="server" Width="80px"
Height="8px">Lo gout</asp:linkbutton> </asp:TableCell>
<asp:TableCel l>
<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:TableCel l>
<uc1:Menu id="Menu1" runat="server"> </uc1:Menu>
</asp:TableCell>
<asp:TableCel l>
<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 MyDataTableOfMe nus
dim link as string = cstr(row("link" ))
dim name as string = cstr(row("name" ))
dim childRows as DataRow() = row.GetChildRow s("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.C ontrols.Add(td)
if childRows.Lengt h > 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.GetChildRow s("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***@discussi ons.microsoft.c om> wrote in message
news:F2******** *************** ***********@mic rosoft.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="MenuContain er" runat="server"
</tr>

and in your codebehind do:

for each row as DataRow in MyDataTableOfMe nus
dim link as string = cstr(row("link" ))
dim name as string = cstr(row("name" ))
dim td as HtmlTableCell = CreateMenuItem( link, name)
MenuContainer.C Ontrols.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***@discussi ons.microsoft.c om> wrote in message
news:FA******** *************** ***********@mic rosoft.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:TableCel l>
> <asp:linkbutt on id="btnLogOut" style="Z-INDEX: 102; LEFT: 8px; TOP:
> 8px" runat="server" Width="80px"
> Height="8px">Lo gout</asp:linkbutton> </asp:TableCell>
> <asp:TableCel l>
> <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:TableCel l>
> <uc1:Menu id="Menu1" runat="server"> </uc1:Menu>
> </asp:TableCell>
> <asp:TableCel l>
> <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
7833
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 creates a different sub-menu for each of them. This sub-menu is just a single image the way I've created it.... What I'm trying to do is now link various parts of the sub-menu to various page links or actions.
9
1274
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 behind pages). Somehow, I've managed to either remove it, or it's been phased out. Anyone know how to get it back? Yep - I admit, I'm lazy and I liked the command. - Chad
3
2129
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 menu options are displayed thanks a lot -- AdamPC@hotmail.com
1
3219
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 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...
5
5854
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 users to click on another category and have that expand). Example:
1
2329
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 an answer. I've worked on this for days. Help will be appreciated. The website is: www.457thbombgroup.org/indexRR.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 TRANSITIONAL//EN"> <html>
1
1953
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 script allows you to select more that one menu and have them all open which is not what I want. Can anyone please help? This menu can be found at
1
2660
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' align='center' cellpadding='1' cellspacing='0'>"; foreach($rs->fetch() as $prs){ $htmlOut .="<tr><td class=\"projectkiri\" ><a href=\"/index.php?page=PROJECTS&id=".$prs."\">".$prs."</a></td></tr>";
0
8707
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9314
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9174
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9015
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7953
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6634
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5947
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4464
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4725
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.