First Post:
In the template page, select the page above and the background of the current page is displayed in blue.
Template page content:
CSS
CSS
This is a style sheet file.
<Style type = "text/css">
# Nav
{
Height: 26px;
Border-bottom: 2px solid # 2788da;
List-style: none;
}
# Nav li
{
Float: left;
}
# Nav li
{
Color: #000000;
Text-decoration: none;
Padding-top: 4px;
Display: block;
Width: 120px;
Height: 22px;
Text-align: center;
Background-color: # ececec;
Margin-left: 2px;
}
# Nav li a: hover
{
Background-color: # bbbbbb;
Color: # ffffff;
}
# Nav li a # current
{
Background-color: # 2788da;
Color: # fff;
}
</Style>
HTML code:
HTML
<Form id = "form1" runat = "server">
<Div>
<Ul id = "nav">
<Li> <a href = "Home. aspx"> HOME </a> </li>
<Li> <a href = "Aspnet. aspx"> ASP. NET </a> </li>
<Li> <a href = "PHP. aspx"> PHP </a> </li>
<Li> <a href = "#"> JAVASCRIPT </a> </li>
<Li> <a href = "#"> SEO </a> </li>
<Li> <a href = "#"> SQLSERVER </a> </li>
<Li> <a href = "#"> JQuery </a> </li>
</Ul>
<Asp: ContentPlaceHolder ID = "ContentPlaceHolder1" runat = "server">
</Asp: ContentPlaceHolder>
</Div>
<Script language = "javascript" type = "text/javascript">
Var obj = null;
Var As = document. getElementById ('nav'). getElementsByTagName ('A ');
Obj = As [0];
For (I = 1; I <As. length; I ++ ){
If (window. location. href. indexOf (As [I]. href)> = 0)
Obj = As [I];
}
Obj. id = 'current'
</Script>
</Form>
The js Code changes the id attribute of the <a> label based on the current URL to change the navigation style of the current page.
After the asp.net page references the template page, modify the URL of the <a> tab to the page address.