BlakeMcKenna
asked on
Changing the BackColor of an ASP MenuItem programmatically?
I"m using VB.Net and I have a master page that contains an asp Menu control that contains 7 parent items. What I'm trying to do in the code-behind file is change the backcolor of each parent item except 1 (which is a "Login" menuItem). I have a For Loop that disables each menu item until the user has successfully logged in, however, I want to change the backcolor also to visually let the user know they are or are not logged in. How can I do this? My code is below.
Private Sub DisableMenu()
Try
For Each mnu As MenuItem In Menu1.Items
If mnu.Value = "mnuLogin" Then
Else
'Change the BackColor for each Parent Item
mnu.Enabled = False
End If
Next
Catch ex As Exception
lblMessage.Text = dbIO.DisplayError("DisableMenu()", "SiteMP", ex.Message)
End Try
End Sub
Have a look at the options posted here: http://stackoverflow.com/questions/705440/asp-net-menuitem-individual-styles
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think I'll try another route altogether. Thanks for the input though! You can close this quesiton.
Experts have already provided solutions to the problem as it was posted. The fact that the poster eventually decided to change the architecture of his application should not prejudice the experts that provided solutions to the presented scenario.
MenuItem does not have a BackColor property, but you can use the DrawItem Event to do it
http://msdn.microsoft.com/en-us/library/system.windows.forms.menuitem.drawitem.aspx#Y300