I look around, but I can’t find anything that matches my problem.
I do this in C # asp.net visual studio 2005, I have a main page and removed the Page_Load event from there, since I wanted Page_Load on pages other than the wizard to fire. So, on one of the pages, except for the main page:
on page 1.aspx:
public partial class page1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
(this.Master as IMasterPage).SetSelected("gtm");
}
}
in masterpage.cs:
public partial class Master : System.Web.UI.MasterPage, IMasterPage
{
#region ImasterPage Members
public void SetSelected(string name)
{
switch (name)
{
case "gtm":
this.gtm.CssClass = "gtm_sel";
break;
default: break;
}
}
#endregion
}
the codes shown are for a horizontal, single-level main menu somewhere on top of the page, and I wanted the selected menu to stand out after the page was reloaded, but page_load on page1.aspx did not seem to be called!
This is part of the menu on the main page:
<div id="menu" class=''>
<ul>
<li><asp:HyperLink ID="com" CssClass="gtm" runat="server" NavigateUrl="~/page1.aspx"><span>Courses</span></asp:HyperLink></li>
<li><asp:HyperLink ID="tbm" CssClass="tbm" runat="server" NavigateUrl="~/page2.aspx"><span>Team Building</span></asp:HyperLink></li>
<li><asp:HyperLink ID="ptm" CssClass="ptm" runat="server" NavigateUrl="~/page3.aspx"><span>Personal Training</span></asp:HyperLink></li>
<li><asp:HyperLink ID="atm" CssClass="atm" runat="server" NavigateUrl="~/page4.aspx"><span>Adventure Tours</span></asp:HyperLink></li>
<li><asp:HyperLink ID="gtm" CssClass="stm" runat="server" NavigateUrl="~/groupTraining.aspx"><span>Group Training</span></asp:HyperLink></li>
</ul>
</div>
CSS (: gtm_sel) , page1.aspx page_load , , : this.SetSelected( '');
haywired.