Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have a problem with tab color display and tab binding.

when i select the tab. the color will be displaying perfectly.

But, the tab is not selecting what i am selected particular tab in diff.color

what is the problem..?

because of this i have spent half day...?

pls. give me solution where i am wrong..?

see my code
-----------
ASPX Code
---------
<tr>
                   <td width="100%">
                         <div id="Div1" class="mattblackmenu">
                        <asp:Menu id="NavigationMenu" Runat="Server" Orientation="Horizontal"
                            StaticMenuStyle-VerticalPadding="2"
                            StaticMenuItemStyle-Font-Name="Verdana"
                            StaticMenuItemStyle-Font-Size="8pt"
                            StaticMenuItemStyle-ForeColor="white"
                            StaticHoverStyle-BackColor="RED"
                            StaticHoverStyle-ForeColor="RED"
                            StaticSelectedStyle-Font-Bold="True"
                            StaticSelectedStyle-BackColor="white"
                            StaticSelectedStyle-ForeColor="RED">
                        
                        </div>
                    </td>
                    <td style="width:400px; vertical-align:top">
                        <asp:ContentPlaceHolder id="CONTENT" Runat="Server"/>
                    </td>
            </tr>

Class CSS File () - "class="mattblackmenu"
-------------------------------------------
C#
.mattblackmenu ul{
margin: 0;
padding: 0;
font: bold 11px Verdana;
list-style-type: none;
border-bottom: 1px solid gray;
background: #414141;
overflow: hidden;
width: 100%;
}
.mattblackmenu li{
display: inline;
margin: 0;
}
.mattblackmenu li a
{
	float: left;
	display: block;
	text-decoration: none;
	margin: 0;
	padding: 5px 8px; /*padding inside each tab*/
	border-right: 1px solid white; /*right divider between tabs*/
	color: #FFFFFF;
	background: #000000;
	filter:progid:DXImageTransform.Microsoft.Gradient(endColorstr='#75808a', startColorstr='#000000', gradientType='0');   
}
.mattblackmenu li a:visited{
color: white;
}
.mattblackmenu li a:hover{
background: black; /*background of tabs for hover state */
}
.mattblackmenu a.selected{
background: black; /*background of tab with "selected" class assigned to its LI */
}
/*Modal Popup*/
.modalBackground {
 background-color:Gray; 
 -ms-filter: alpha(opacity=70);
 -ms-opacity:0.7;
}



ASPX.VB Code
------------

VB
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        MnuItemSelected()
        If Not IsPostBack Then
            FillMenuData()
        End If
        'check whether session expires
        Me.CheckSessionTimeout()
 End Sub
 Public Sub FillMenuData()
NavigationMenu.Items.Clear()
        Conn.Open()
        StrQry = ""
        StrQry = " Select isnull(Adm,'') as Admin,isnull(Home,'') as Home,"
        StrQry &= " isnull(Proj,'') as Projects
        StrQry &= " from Projects where emp_number ='" & Session("EmpNo") & "' "
        
        Cmd.Connection = Conn
        Cmd.CommandText = StrQry
        Rdr = Cmd.ExecuteReader
        If Rdr.HasRows Then
            While Rdr.Read
                If Rdr("Home") = "Y" Then
                    Dim mnuItems As New MenuItem()
                    mnuItems.NavigateUrl = "~\Home.aspx"
                    mnuItems.Text = "Home"
                    NavigationMenu.Items.Add(mnuItems)
                End If
                If Rdr("Adm") = "Y" Then
                    Dim mnuItems As New MenuItem()
                    mnuItems.NavigateUrl = "~\Adm.aspx"
                    mnuItems.Text = "Adm"
                    NavigationMenu.Items.Add(mnuItems)
                End If
                If Rdr("Proj") = "Y" Then
                    Dim mnuItems As New MenuItem()
                    mnuItems.NavigateUrl = "~\Proj.aspx"
                    mnuItems.Text = "Proj"
                    NavigationMenu.Items.Add(mnuItems)
                End If
            End While
        End If
        Rdr.Close()
        Conn.Close()
 End Sub
 Private Sub MnuItemSelected()
        '-- Get page name from relative path
        Dim ThisPage As String = Page.AppRelativeVirtualPath
        Dim SlashPos As Integer = InStrRev(ThisPage, "/")
        Dim PageName As String = Right(ThisPage, Len(ThisPage) - SlashPos)
        '-- Select menu item with matching NavigateUrl property
        Dim ParentMenu As New MenuItem
        Dim ChildMenu As New MenuItem
        NavigationMenu.Items.Clear()
        For Each ParentMenu In NavigationMenu.Items
            If ParentMenu.NavigateUrl = PageName Then
                ParentMenu.Selected = True
            Else
                For Each ChildMenu In ParentMenu.ChildItems
                    If ChildMenu.NavigateUrl = PageName Then
                        ChildMenu.Selected = True
                    End If
                Next
            End If
        Next
    End Sub
Posted
Updated 2-Aug-11 3:36am
v3

1 solution

after selecting a menu choice your menu gives a postback.... so it does not know what was clicked.
 
Share this answer
 
Comments
gani7787 2-Aug-11 10:21am    
Thanks...i added before postback and after selected the menu...it's working...
RaisKazi 2-Aug-11 11:48am    
5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900