I have an ASP.NET/C# page that uses jQuery to load a Navigation.aspx page that contains my header and navigation buttons:
<script>
$(function(){
$("#nav-placeholder").load("Navigation.aspx");
});
</script>
In the code behind of the Navigation.aspx page, I have a block of code that needs to get the name of the page that it's being loaded by. What I'm trying to do is highlight the navigation button of the current page. So, if I have a Manufacturing.aspx page that loads the Navigation.aspx page, I need to see the calling page's name in order to highlight the corresponding button, like so:
string pageName = Path.GetFileName(Request.Path);
if (pageName == "Manufacturing.aspx")
{
btnManufacturing.Attributes.CssStyle.Add("background-color", "deepskyblue");
}
The sample above retrieves the Navigation.aspx page name, not Manufacturing.aspx. Does anyone know of a way to accomplish this?
I might be able to do the same thing by accessing the items on the loaded page from the Manufacturing page and then updating the CSS in the code behind, but I haven't found a way to access those items either (for example, the btnManufacturing item in Navigation.asp). Thanks in advance!