T
theintrepidfox
Dear Group
I'd be grateful if one of you can help me out with the following.
I'd like to load a resource string dynamically e.g.
Resources.Default.aspx.mnuNavigation1 should load the corresponding
string. The enumerator of the resource string to load is a row ID in a
database e.g. 1,2,3 etc which is appended to
Resources.Default.aspx.mnuNavigation.
It works so far that it poulates the text property of each menu item
with the corresponding key path, e.g.
'Resources.Default.aspx.mnuNavigation1' is displayed but not the key.
See samples below.
Any ideas on how do do this are very much appreciated.
Thank you for your time & efforts!
Martin
Code:
Private Sub LoadNavigationMenu()
mnuNavigation.Items.Clear()
Dim str1 As String = "EXEC th_GetNavigationSelection"
Dim cmd1 As New SqlClient.SqlCommand(str1,
clsData.GetSQLConnection())
clsData.OpenSQLConnection()
Dim ItemReader As SqlClient.SqlDataReader =
cmd1.ExecuteReader()
While ItemReader.Read
Dim mnuItem As New MenuItem
Dim ResString As Object =
"Resources.Default.aspx.mnuNavigation" + ItemReader.Item(0).ToString()
mnuItem.Text = ResString
If CBool(ItemReader.Item(1)) = True Then
mnuNavigation.Items.Add(mnuItem)
End If
End While
ItemReader.Close()
clsData.CloseSQLConnection()
End Sub
Resource File Content:
mnuNavigation1,"Best Deals"
mnuNavigation1,"Best Value"
mnuNavigation1,"Location"
mnuNavigation1,"Map"
mnuNavigation1,"Postcode"
I'd be grateful if one of you can help me out with the following.
I'd like to load a resource string dynamically e.g.
Resources.Default.aspx.mnuNavigation1 should load the corresponding
string. The enumerator of the resource string to load is a row ID in a
database e.g. 1,2,3 etc which is appended to
Resources.Default.aspx.mnuNavigation.
It works so far that it poulates the text property of each menu item
with the corresponding key path, e.g.
'Resources.Default.aspx.mnuNavigation1' is displayed but not the key.
See samples below.
Any ideas on how do do this are very much appreciated.
Thank you for your time & efforts!
Martin
Code:
Private Sub LoadNavigationMenu()
mnuNavigation.Items.Clear()
Dim str1 As String = "EXEC th_GetNavigationSelection"
Dim cmd1 As New SqlClient.SqlCommand(str1,
clsData.GetSQLConnection())
clsData.OpenSQLConnection()
Dim ItemReader As SqlClient.SqlDataReader =
cmd1.ExecuteReader()
While ItemReader.Read
Dim mnuItem As New MenuItem
Dim ResString As Object =
"Resources.Default.aspx.mnuNavigation" + ItemReader.Item(0).ToString()
mnuItem.Text = ResString
If CBool(ItemReader.Item(1)) = True Then
mnuNavigation.Items.Add(mnuItem)
End If
End While
ItemReader.Close()
clsData.CloseSQLConnection()
End Sub
Resource File Content:
mnuNavigation1,"Best Deals"
mnuNavigation1,"Best Value"
mnuNavigation1,"Location"
mnuNavigation1,"Map"
mnuNavigation1,"Postcode"