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.databindings.item(0) - (11)).
(Personally, I don't understand why this is so difficult) Here's my code:
Public Sub BuildMenus(ByVal connString As String, ByVal menuName As
System.Web.UI.WebControls.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.Page, ByVal siteId As Integer, ByVal applicationId As
String, ByVal userId As Integer)
Dim StoreErrorMessage As New SystemTools.StoreErrorMessages(MyPage)
Dim OpenConnection As New IO.OpenConnection
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.SqlCommand(storedProcedure, sqlConn)
sqlCmd.CommandType = CommandType.StoredProcedure
sqlCmd.Parameters.AddWithValue("@SiteID", siteId)
sqlCmd.Parameters.AddWithValue("@UserID", userId)
sqlCmd.Parameters.AddWithValue("@SortOrder", sortOrder)
sqlCmd.Parameters.AddWithValue("@OrderBy", orderBy)
sqlCmd.Parameters.AddWithValue("@WhereClause", whereClause)
Try
dr = sqlCmd.ExecuteReader(CommandBehavior.CloseConnecti on)
Catch ex As Exception
DispMessage("Determine Menus Error - " & ex.Message, MyPage)
StoreErrorMessage.StoreSystemErrorMessage(connStri ng,
applicationId, "", "BuildMenus", "GenericRoutines.vb", ex.Message, "")
End Try
End If
If Not dr Is Nothing Then
' [rak] Dim MenuDoc As XmlDocument
While dr.Read
menuName.DataBindings.Add(BuildSimpleMenuBinding(d r.Item("SortID"),
dr.Item("HLevel"), dr.Item("MenuName"), Convert.ToString(dr.Item("Url"))))
'[rak] BindMenuToXmlDocument(MenuDoc, menuName, "menu/item")
End While
menuName.databind()
dr.Close()
End If
End Sub
Public Function BuildSimpleMenuBinding(ByVal XmlElementName As String,
ByVal Depth As Integer, ByVal TextField As String, ByVal NavigationUrlField
As String) As MenuItemBinding
Dim MenuBinding As MenuItemBinding = New MenuItemBinding
MenuBinding.DataMember = XmlElementName
MenuBinding.TextField = TextField
MenuBinding.NavigateUrlField = NavigationUrlField
MenuBinding.Depth = Depth
Return MenuBinding
End Function
Public Sub BindMenuToXmlDocument(ByVal MenuDocument As XmlDocument,
ByRef MenuControl As System.Web.UI.WebControls.Menu, ByVal XPath As String)
Dim MenuDataSource As XmlDataSource = New XmlDataSource()
MenuDataSource.Data = MenuDocument.OuterXml
MenuDataSource.EnableCaching = False
MenuDataSource.XPath = XPath
MenuControl.DataSource = MenuDataSource
MenuControl.DataBind()
End Sub
thanks
rob 1 1796
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***@discussions.microsoft.comwrote in message
news:33**********************************@microsof t.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.databindings.item(0) - (11)).
(Personally, I don't understand why this is so difficult) Here's my code:
Public Sub BuildMenus(ByVal connString As String, ByVal menuName As
System.Web.UI.WebControls.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.Page, ByVal siteId As Integer, ByVal applicationId As
String, ByVal userId As Integer)
Dim StoreErrorMessage As New SystemTools.StoreErrorMessages(MyPage)
Dim OpenConnection As New IO.OpenConnection
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.SqlCommand(storedProcedure, sqlConn)
sqlCmd.CommandType = CommandType.StoredProcedure
sqlCmd.Parameters.AddWithValue("@SiteID", siteId)
sqlCmd.Parameters.AddWithValue("@UserID", userId)
sqlCmd.Parameters.AddWithValue("@SortOrder", sortOrder)
sqlCmd.Parameters.AddWithValue("@OrderBy", orderBy)
sqlCmd.Parameters.AddWithValue("@WhereClause", whereClause)
Try
dr = sqlCmd.ExecuteReader(CommandBehavior.CloseConnecti on)
Catch ex As Exception
DispMessage("Determine Menus Error - " & ex.Message,
MyPage)
StoreErrorMessage.StoreSystemErrorMessage(connStri ng,
applicationId, "", "BuildMenus", "GenericRoutines.vb", ex.Message, "")
End Try
End If
If Not dr Is Nothing Then
' [rak] Dim MenuDoc As XmlDocument
While dr.Read
menuName.DataBindings.Add(BuildSimpleMenuBinding(d r.Item("SortID"),
dr.Item("HLevel"), dr.Item("MenuName"), Convert.ToString(dr.Item("Url"))))
'[rak] BindMenuToXmlDocument(MenuDoc, menuName,
"menu/item")
End While
menuName.databind()
dr.Close()
End If
End Sub
Public Function BuildSimpleMenuBinding(ByVal XmlElementName As String,
ByVal Depth As Integer, ByVal TextField As String, ByVal
NavigationUrlField
As String) As MenuItemBinding
Dim MenuBinding As MenuItemBinding = New MenuItemBinding
MenuBinding.DataMember = XmlElementName
MenuBinding.TextField = TextField
MenuBinding.NavigateUrlField = NavigationUrlField
MenuBinding.Depth = Depth
Return MenuBinding
End Function
Public Sub BindMenuToXmlDocument(ByVal MenuDocument As XmlDocument,
ByRef MenuControl As System.Web.UI.WebControls.Menu, ByVal XPath As
String)
Dim MenuDataSource As XmlDataSource = New XmlDataSource()
MenuDataSource.Data = MenuDocument.OuterXml
MenuDataSource.EnableCaching = False
MenuDataSource.XPath = XPath
MenuControl.DataSource = MenuDataSource
MenuControl.DataBind()
End Sub
thanks
rob This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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).
...
|
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...
|
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...
|
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...
|
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...
| |
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...
|
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...
|
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...
|
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...
|
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...
|
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,...
| |
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,...
|
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...
|
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,...
|
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...
|
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...
|
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...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |