473,597 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamic asp:menu rendering

hi folks

i want complete control of my menuing in ASP (no site maps, no hardwired XML
files, etc.) This is all governed by SiteID, ApplicationID, UserID, etc.

i thought i was close with this, but nothing is rending in the control/on
the page (even though I see my 12 items in the databindings are there
menuName.databi ndings.item(0) - (11)).

(Personally, I don't understand why this is so difficult) Here's my code:

Public Sub BuildMenus(ByVa l connString As String, ByVal menuName As
System.Web.UI.W ebControls.Menu , ByVal storedProcedure As String, ByVal
idFieldName As String, ByVal fieldName As String, ByVal sortOrder As String, _
ByVal orderBy As String, ByVal whereClause As String, ByVal MyPage
As System.Web.UI.P age, ByVal siteId As Integer, ByVal applicationId As
String, ByVal userId As Integer)

Dim StoreErrorMessa ge As New SystemTools.Sto reErrorMessages (MyPage)
Dim OpenConnection As New IO.OpenConnecti on

Dim dr As SqlDataReader = Nothing
Dim sqlConn As SqlConnection =
OpenConnection. openConnection( connString, MyPage)

If Not sqlConn Is Nothing Then

Dim sqlCmd As SqlCommand = New
SqlClient.SqlCo mmand(storedPro cedure, sqlConn)

sqlCmd.CommandT ype = CommandType.Sto redProcedure
sqlCmd.Paramete rs.AddWithValue ("@SiteID", siteId)
sqlCmd.Paramete rs.AddWithValue ("@UserID", userId)
sqlCmd.Paramete rs.AddWithValue ("@SortOrder ", sortOrder)
sqlCmd.Paramete rs.AddWithValue ("@OrderBy", orderBy)
sqlCmd.Paramete rs.AddWithValue ("@WhereClause" , whereClause)

Try
dr = sqlCmd.ExecuteR eader(CommandBe havior.CloseCon nection)
Catch ex As Exception
DispMessage("De termine Menus Error - " & ex.Message, MyPage)
StoreErrorMessa ge.StoreSystemE rrorMessage(con nString,
applicationId, "", "BuildMenus ", "GenericRoutine s.vb", ex.Message, "")
End Try
End If

If Not dr Is Nothing Then
' [rak] Dim MenuDoc As XmlDocument
While dr.Read

menuName.DataBi ndings.Add(Buil dSimpleMenuBind ing(dr.Item("So rtID"),
dr.Item("HLevel "), dr.Item("MenuNa me"), Convert.ToStrin g(dr.Item("Url" ))))
'[rak] BindMenuToXmlDo cument(MenuDoc, menuName, "menu/item")
End While

menuName.databi nd()
dr.Close()
End If
End Sub
Public Function BuildSimpleMenu Binding(ByVal XmlElementName As String,
ByVal Depth As Integer, ByVal TextField As String, ByVal NavigationUrlFi eld
As String) As MenuItemBinding

Dim MenuBinding As MenuItemBinding = New MenuItemBinding
MenuBinding.Dat aMember = XmlElementName
MenuBinding.Tex tField = TextField
MenuBinding.Nav igateUrlField = NavigationUrlFi eld
MenuBinding.Dep th = Depth

Return MenuBinding
End Function
Public Sub BindMenuToXmlDo cument(ByVal MenuDocument As XmlDocument,
ByRef MenuControl As System.Web.UI.W ebControls.Menu , ByVal XPath As String)

Dim MenuDataSource As XmlDataSource = New XmlDataSource()
MenuDataSource. Data = MenuDocument.Ou terXml
MenuDataSource. EnableCaching = False
MenuDataSource. XPath = XPath
MenuControl.Dat aSource = MenuDataSource
MenuControl.Dat aBind()
End Sub

thanks
rob


Jun 27 '08 #1
1 1802
Consider trying a custom sitemap provider that looks at the database instead
of a site map file. You can then control things however you desire.

As for the particular issues, I would set some breakpoints in the method
that binds and make sure you are actually grabbing the XML document. If you
are, then you have to dig deeper. If you are using Visual Studio 2008, you
can actually debug into the .NET assemblies and see what is going on there.
View source may also give you some hints.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************** *************** *************** ****
| Think outside the box!
|
*************** *************** *************** ****
"tutor" <tu***@discussi ons.microsoft.c omwrote in message
news:33******** *************** ***********@mic rosoft.com...
hi folks

i want complete control of my menuing in ASP (no site maps, no hardwired
XML
files, etc.) This is all governed by SiteID, ApplicationID, UserID, etc.

i thought i was close with this, but nothing is rending in the control/on
the page (even though I see my 12 items in the databindings are there
menuName.databi ndings.item(0) - (11)).

(Personally, I don't understand why this is so difficult) Here's my code:

Public Sub BuildMenus(ByVa l connString As String, ByVal menuName As
System.Web.UI.W ebControls.Menu , ByVal storedProcedure As String, ByVal
idFieldName As String, ByVal fieldName As String, ByVal sortOrder As
String, _
ByVal orderBy As String, ByVal whereClause As String, ByVal MyPage
As System.Web.UI.P age, ByVal siteId As Integer, ByVal applicationId As
String, ByVal userId As Integer)

Dim StoreErrorMessa ge As New SystemTools.Sto reErrorMessages (MyPage)
Dim OpenConnection As New IO.OpenConnecti on

Dim dr As SqlDataReader = Nothing
Dim sqlConn As SqlConnection =
OpenConnection. openConnection( connString, MyPage)

If Not sqlConn Is Nothing Then

Dim sqlCmd As SqlCommand = New
SqlClient.SqlCo mmand(storedPro cedure, sqlConn)

sqlCmd.CommandT ype = CommandType.Sto redProcedure
sqlCmd.Paramete rs.AddWithValue ("@SiteID", siteId)
sqlCmd.Paramete rs.AddWithValue ("@UserID", userId)
sqlCmd.Paramete rs.AddWithValue ("@SortOrder ", sortOrder)
sqlCmd.Paramete rs.AddWithValue ("@OrderBy", orderBy)
sqlCmd.Paramete rs.AddWithValue ("@WhereClause" , whereClause)

Try
dr = sqlCmd.ExecuteR eader(CommandBe havior.CloseCon nection)
Catch ex As Exception
DispMessage("De termine Menus Error - " & ex.Message,
MyPage)
StoreErrorMessa ge.StoreSystemE rrorMessage(con nString,
applicationId, "", "BuildMenus ", "GenericRoutine s.vb", ex.Message, "")
End Try
End If

If Not dr Is Nothing Then
' [rak] Dim MenuDoc As XmlDocument
While dr.Read

menuName.DataBi ndings.Add(Buil dSimpleMenuBind ing(dr.Item("So rtID"),
dr.Item("HLevel "), dr.Item("MenuNa me"), Convert.ToStrin g(dr.Item("Url" ))))
'[rak] BindMenuToXmlDo cument(MenuDoc, menuName,
"menu/item")
End While

menuName.databi nd()
dr.Close()
End If
End Sub
Public Function BuildSimpleMenu Binding(ByVal XmlElementName As String,
ByVal Depth As Integer, ByVal TextField As String, ByVal
NavigationUrlFi eld
As String) As MenuItemBinding

Dim MenuBinding As MenuItemBinding = New MenuItemBinding
MenuBinding.Dat aMember = XmlElementName
MenuBinding.Tex tField = TextField
MenuBinding.Nav igateUrlField = NavigationUrlFi eld
MenuBinding.Dep th = Depth

Return MenuBinding
End Function
Public Sub BindMenuToXmlDo cument(ByVal MenuDocument As XmlDocument,
ByRef MenuControl As System.Web.UI.W ebControls.Menu , ByVal XPath As
String)

Dim MenuDataSource As XmlDataSource = New XmlDataSource()
MenuDataSource. Data = MenuDocument.Ou terXml
MenuDataSource. EnableCaching = False
MenuDataSource. XPath = XPath
MenuControl.Dat aSource = MenuDataSource
MenuControl.Dat aBind()
End Sub

thanks
rob

Jun 27 '08 #2

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

Similar topics

1
340
by: Cornelius | last post by:
Hi, I have a debugging problem! I made a dynamic menu via js: - onload the js scans for all spans with a special id, these spans contain different sets of input controls (generated via ASP). - the menu script gets its information via substrings of the ids and takes it for menu caption. The menu will be generated then and put into another span via innerHTML.
7
2839
by: zorhel | last post by:
Hi. I will do a dynamic menu for a asp.net app.. I don't know yet if how I will get the data for populate this menu: from a sql server database, xml file or what, but I know it will be dynamic any probably encapsulated in a control (user or custom). Someone have any logic code, samples, links for that? Thanks Zorhel
4
2693
by: spx27 | last post by:
Does anyone know the best way to handle passing a dynamic menu generated from a login from one asp.net page to another. Would it be better to recreate the menu on each page? Save the menu as a string into a session variable upon login? Any other way to do this I may be missing? This menu is part of an intranet. The user logs in, checks SQL database for folder permissions, then scans web directories for all folders which match permissions...
1
1365
by: biela | last post by:
Hi I'm from Poland and I have small question :). I'm looking for sample example how to create dynamic menu. Generaly my website will see like that ------------------------------------ 2 ---------|--------------|----------- | | 1 | 3 | 4 | |
7
2672
by: Chuck Hartman | last post by:
I have a Windows service that requests web pages from a site using an HttpWebRequest object. When I try to request a page from an ASP.NET 2 site, I get a WebException with message "The remote server returned an error: (500) Internal Server Error." I found a post that suggested to catch the WebException to retrieve the actual HttpWebResponse object for more information. The response returned is shown below. At first I thought this was a...
7
2418
by: tfsmag | last post by:
Has anyone had a problem with putting a menu control into a master page in .net 2.0? I have a problem where if i just drop a menu control on a regular page the menu works fine, the submenus work perfect. But if I put that exact same code inside a master page, when i go to view one of the files that use that master page, all of the submenus are out of wack and instead of being hidden, they are at the bottom of the menu, and only go back in...
0
1445
by: Vidula | last post by:
I am using the menu control in ASP.NET using VS2005. I want to change the background color of the dynamic menu when the mouse hovers over that menu item. This works fine when the background color style is included in the DynamicHoverStyle tag. But when I am using a cssclass for the DynamicHoverStyle, then this does not work. The background color does not change to the color specified in the cssclass.
0
2007
by: =?Utf-8?B?QmlzaG95?= | last post by:
Hi All, I have a Right to Left web page with asp.net 2.0 containing a horizontal menu. The menu is right to left as the page. The problem is the submenu items or the dynamic menu items are not aligned right, so the menu has a bad shape. -------------------------------------------------------------
0
1366
by: Oded Dror | last post by:
Hi there, I'm using ASP.NET 2.0 with VWD 2005 I created a master page with web sitemap And attached Dynamic Menu Now when I set all dynamic menu properties to BackColor = Transparent Everything looks fine except the Dynamic Menu Style It keep show white background even the back color set to transparent
4
4063
by: SAL | last post by:
Hello, is there a way to menu control dynamically center itself horizontally on a page? I have placed a menu control in a panel control (no ajax) and would like it to center itself. Depending on whose logged in, the menu, or course, displays different items, sometimes just two items, other times many more. If all menu items are displaying, centering is not a problem but when only two items are displayed, the menu appears on the left hand...
0
7969
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8272
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...
1
8035
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6688
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
5847
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
3886
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...
1
2404
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1494
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1238
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.