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()
            For Each mnu As MenuItem In Menu1.Items
                If mnu.Value = "mnuLogin" Then
                    'Change the BackColor for each Parent Item
                    mnu.Enabled = False
                End If

        Catch ex As Exception
            lblMessage.Text = dbIO.DisplayError("DisableMenu()", "SiteMP", ex.Message)
        End Try
    End Sub

Open in new window

Who is Participating?
HainKurtConnect With a Mentor Sr. System AnalystCommented:

MenuItem does not have a BackColor property, but you can use the DrawItem Event to do it
BlakeMcKennaAuthor Commented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.