C
CJM
I have a ASP.NET site with a simple, standard menu:
<div id="menu">
<ul>
<li><a class="selected" id="home" href="index.aspx">Home</a></li>
<li><a id="about" href="/about/">About Us</a></li>
<li><a id="services" href="/services/">Services</a></li>
<li><a id="resources" href="/resources/">Resources</a></li>
<li><a id="contact" href="/contact/">Contact Us</a></li>
</ul>
</div>
As you can see, the Home menu item has the class 'selected', such that it
will render differently to the others to indictate the current page.
There is some code both before and after this section that is standard
across all pages, so I want pull all this html out and place it in an
INCLUDEd file. However, setting the class for the appropriate menu isn't
immediately possible in this example.
I could manually set the class of the element in javascript after the menu
is INCLUDEd, but I thought I'd set it in the codebehind page instead...
except I haven't got a clue how to achieve this (or even if it is possible).
How would I set the class of a particular element in ASP.NET (VB)?
I know the javascript option is easy, but a) there is a small possibility
that javascript will be disable on a client browser, and b) I'm using this
as a learning vehicle for ASP.NET.
Thanks in advance.
CJM
<div id="menu">
<ul>
<li><a class="selected" id="home" href="index.aspx">Home</a></li>
<li><a id="about" href="/about/">About Us</a></li>
<li><a id="services" href="/services/">Services</a></li>
<li><a id="resources" href="/resources/">Resources</a></li>
<li><a id="contact" href="/contact/">Contact Us</a></li>
</ul>
</div>
As you can see, the Home menu item has the class 'selected', such that it
will render differently to the others to indictate the current page.
There is some code both before and after this section that is standard
across all pages, so I want pull all this html out and place it in an
INCLUDEd file. However, setting the class for the appropriate menu isn't
immediately possible in this example.
I could manually set the class of the element in javascript after the menu
is INCLUDEd, but I thought I'd set it in the codebehind page instead...
except I haven't got a clue how to achieve this (or even if it is possible).
How would I set the class of a particular element in ASP.NET (VB)?
I know the javascript option is easy, but a) there is a small possibility
that javascript will be disable on a client browser, and b) I'm using this
as a learning vehicle for ASP.NET.
Thanks in advance.
CJM