I am not a .Net guy but trying to get update an existing .net site. Trying to set up a unique id for the body tag even though I am using a master page.
<body id="<% page_name %>">
Obviously the above example doesn’t work but not quite sure if there is a function that returns the file name that can be easily added to the masterpage so it give each page’s body tag a unique “id” based on the page name.
I would perfer not having to set some variable up on each code behind page but just once on the master page.
Could be going about this the completely wrong way. Using PHP I have done this a number of times.
Basically I am trying to get a unique body id for each of the pages of the site. This will allow me to use CSS to style page specific layout items.
I’ve done exactly what you’re talking about. This is how I did it.
What you have in the body tag is pretty close. This is what I’ve used in the masterpage’s markup, it’s a code behind method.
In the masterpage code behind, you need this using statement:
Basically what this does is gets the file name of the page that you will be accessing during runtime.
The following methods are used to grab the file name of the page, and then assign that file name as a unique id to the generated page.
Now you should be able to access that body ID just like you would with any other type of ID. I’ve used this to enable navigation highlighting via a stylesheet. There are a few more steps involved with that, but you can generally find those answers on google.
Good luck, and hope this helps.