Hi,
I am working on an shopping-type site. I have a page where a product is pulled from a database and displayed. Along with the usual product information, it has a single category ID number which tells the ASPX page (product.aspx) which category it is from. The script then uses this number to display the product's category (e.g. books > fiction > crime)
The page has a dynamic navigation menu at the side. This is built/displayed using a compiled control in a DLL.
The menu is an extension of a standard ASP.NET XML control. The only difference is that it has an additional property - the category id. It is found on the page as:
Code:
<shop:xmlMenu runat="server" id="LeftMenu" categoryID="15"/>
The compiled control should take the category ID (which can be hard-wired into the .aspx page or set using the code-behind) and dynamically build an XML menu which is transformed using XSLT. There are various reasons for doing it this way.
The result is that the menu expands and contracts depending on which section you are browsing.
HOWEVER, the compiled control does not seem able to access the public
property!
I know the script works without using a property as I originally planned to use a query string to get the category id. It just doesn't seem to work with a property
The code for the compiled control is:
Code:
Public Class XmlMenu
Inherits System.Web.UI.WebControls.Xml
Public sCategoryID As Integer = 0 'Default value
Public Property CategoryID As Integer
Get
Return sCategoryID
End Get
Set(ByVal Value As Integer)
sCategoryID = value
End Set
End Property
Public Sub New()
Dim NewXml As New XmlDocument()
NewXML = BuildMenu(sCategoryID)
Me.Document = NewXml
Me.TransformSource = "menu.xsl"
End Sub
Public Function BuildMenu(CatID As Integer) As XmlDocument
'Do stuff to generate XML with CatID variable using a database etc.
BuildMenu = MenuXML
End Function
End Class