Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Aug 11, 2006 07:41 AM by publicocean1
Aug 11, 2006 07:41 AM|LINK
I had a very interesting E-Mail exchange with Exo_duz, referring his post from June 2006 about the problem "setting id for menu adapter and output it in the li tags".
I wrote to him:
It was very interesting for me to read about your problem and I think that could be a fine solution. But how can you go further after processing individual IDs for the li tag. Where can they be built in? I tried to get them in the MenuStyle.css but it wasn't
succesfull. Could You give me an advice? Thanks Thomas
I’ve actually changed the code now instead of a page + number (page1, page2, etc) I’ve used another method because the id had to be unique
and the page number will stuff up if I add another page in between other nodes in the web.sitemap file. Look at the following code:
//get the description of the url and create unique page id
//change to lower-case, remove spaces and get the first 6 letters
page_id = item.Text;
page_id = page_id.Trim();
page_id = page_id.ToLower();
page_id = page_id.Replace(" ",
(page_id.Length > 13)
page_id = page_id.Substring(0, 12);
This will remove all whitespaces and convert to lower case. Then if the “title” is more than 12 characters it just truncates it.
Why I’m doing this you ask? This is more for CSS issues. I did this as it was neater to set header tags, div tags and CSS related issues if I needed to change anything
with the styling of the page.
The output of the above code would be, note the id tags that I’ve marked in red:
<li class="AspNet-Menu-Leaf" id="directorsand">
<a href="/CI/directors_management.aspx" class="AspNet-Menu-Link" title="Directors and Management">Directors and Management</a>
This means that I can in the CSS:
Note that I’m using Master Pages and thanks to information I got from this page:
In the master pages I make a publicly accessible variable:
//set the container css class of the master page
The above variable is then accessed from the content page like this:
void Page_Load(xobject sender,
This will then target the h1 tags in the page
If you would like to see an example of this, let me know and I’ll gladly
let you know the URL of the site I use this method on.
Hope this helps. Can you post this question to the forums and I’ll put
this reply on there for you? Just in case someone else needs to use this method.
It would be great to the see the example.