R
Rob Meade
Hi all,
I'm trying to dynamically create the navigation for my web page - I have
achieved this at work and whilst trying to reproduce the code this evening
at home I'm obviously missing something, I just cant see what...
Here's the error:
Class 'System.Web.UI.WebControls.TableRow' cannot be indexed because it has
no default property.
Here's the code for my left navigation web user control.
Imports System.IO
Public Class LeftBorder
Inherits System.Web.UI.UserControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' Declare variables
Dim strCurrentPage As String
Dim tblNavigation As Table
Dim addNavigation As TableRow
tblNavigation = New Table
addNavigation = New TableRow
strCurrentPage = Path.GetFileName(Request.Path)
' Create navigation
tblNavigation.Rows.Add(addNavigation(strCurrentPage, "Home",
"Default.aspx"))
End Sub
End Class
Public Class LeftNavigation
Function addNavigation(ByVal CurrentPage As String, ByVal PageName As
String, ByVal PageLink As String) As TableRow
' Declare variables
Dim Row As TableRow
Dim Cell As TableCell
Dim Link As HyperLink
Link = New HyperLink
If CurrentPage.ToLower = PageName.ToLower Then
Cell.Text = PageName
ElseIf CurrentPage.ToLower <> PageName.ToLower Then
' Set the properties of our link
Link.NavigateUrl = PageLink
Link.CssClass = "normalText"
Link.ToolTip = PageName
Link.Target = "_top"
Cell.Controls.Add(Link)
End If
Row.Cells.Add(Cell)
Return (Row)
End Function
End Class
I think I probably need to change the inherits lines around so that the
second class has the Inherits System.Web.UI.UserControl
and then I derived my main class from that using inherits leftNavigation
etc...
The line I get the error on is the first class where I am calling
addNavigation...
Any help would be appreciated - quite new to this so be gently
Regards
Rob
I'm trying to dynamically create the navigation for my web page - I have
achieved this at work and whilst trying to reproduce the code this evening
at home I'm obviously missing something, I just cant see what...
Here's the error:
Class 'System.Web.UI.WebControls.TableRow' cannot be indexed because it has
no default property.
Here's the code for my left navigation web user control.
Imports System.IO
Public Class LeftBorder
Inherits System.Web.UI.UserControl
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
' Declare variables
Dim strCurrentPage As String
Dim tblNavigation As Table
Dim addNavigation As TableRow
tblNavigation = New Table
addNavigation = New TableRow
strCurrentPage = Path.GetFileName(Request.Path)
' Create navigation
tblNavigation.Rows.Add(addNavigation(strCurrentPage, "Home",
"Default.aspx"))
End Sub
End Class
Public Class LeftNavigation
Function addNavigation(ByVal CurrentPage As String, ByVal PageName As
String, ByVal PageLink As String) As TableRow
' Declare variables
Dim Row As TableRow
Dim Cell As TableCell
Dim Link As HyperLink
Link = New HyperLink
If CurrentPage.ToLower = PageName.ToLower Then
Cell.Text = PageName
ElseIf CurrentPage.ToLower <> PageName.ToLower Then
' Set the properties of our link
Link.NavigateUrl = PageLink
Link.CssClass = "normalText"
Link.ToolTip = PageName
Link.Target = "_top"
Cell.Controls.Add(Link)
End If
Row.Cells.Add(Cell)
Return (Row)
End Function
End Class
I think I probably need to change the inherits lines around so that the
second class has the Inherits System.Web.UI.UserControl
and then I derived my main class from that using inherits leftNavigation
etc...
The line I get the error on is the first class where I am calling
addNavigation...
Any help would be appreciated - quite new to this so be gently

Regards
Rob