I am experiencing the same problem, but I think I found out 'how', just not the 'why'. The master page renders all content to your ContentPlaceHolder on the master page. I've set stops and examined when this bypasses my wired-up events.
It turns out that if you're using something like a menu that 'navigates' to different files in your web project, that act of navigating bypasses any wired events on the mater page. In other words, if you have a Menu on your master page that is not assigned a "NavigateUrl" property, the master page triggers its own events, sets the menu selected item, and does not change the content.
I don't know why it functions this way. This means the css pseudo-element :selected will not be rendered when a Menu in the master page navigates to a content page. It only occurs when it doesn't navigate.
Very odd and frustrating. I'd like my site to make use of its css pseudo-element :selected and run its wired-up events when triggered. Specifically, I'm having problems catching my "MenuItemClick" event in my master page when my Menu uses it NavigateUrl value to render the ContentPlaceHolder.
1.) How can I manually designate the uri/file for the ContentPlaceHolder and render it
~or~
2.) How can I get the Menu to properly make use of the css pseudo-element :selected and allow the master page to trigger the MenuItemClick event for each content page a user visits via the NavigateUrl property of a MenuItem?
Here's my code so far (I've nixed the using statements and other obvious lines, as well as removed my styling so it's less confusing)...
Default.master.cs
public
partial class _Default : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
//wire-up events
this.menuMain.MenuItemClick += new MenuEventHandler(menuMain_MenuItemClick);
if (IsPostBack == false)
//set default page header
lbl_Header.Text = "Home";
}
void menuMain_MenuItemClick(object sender, MenuEventArgs e)
{
//set page header
lbl_Header.Text = menu_MainNavigation.SelectedValue;
//set content
//?how do I manually update content instead of using the NavigatUrl of Menu?
//contentMain. ?? = menu_MainNavigation.Text + ".aspx".;
//would I have to render contentMain manually, and is it possible?
}
}
Default.master
<asp:Menu
id="menuMain"
orientation="Vertical"
runat="server">
<Items>
<asp:MenuItem
Text="somePage"
Value="1st Page Header"
NavigateUrl="somePage.aspx" />
<asp:MenuItem
Text="anotherPage"
Value="2nd Page Header" />
</Items>
</asp:Menu>
<asp:ContentPlaceHolder id="contentMain" runat="server" />
Thanks!
private object yummyFood(baggels,coffee){
foreach(byte in (baggles).code){eat[byte];drink(coffee);}
return discharge(burp);}