views:

168

answers:

1

I have been looking around yet I can't find any that fits in my problem.

I am doing this in c# asp.net visual studio 2005, i have a master page and removed the Page_Load event from there since i wanted the Page_Load in the pages other than the master to fire. So in one of the pages other than the masterpage:

  • in page1.aspx:

    public partial class page1 : System.Web.UI.Page{

     protected void Page_Load(object sender, EventArgs e){
    
    
    
      (this.Master as IMasterPage).SetSelected("gtm");
    
    }

    }

  • and in masterpage.cs:

    public partial class Master : System.Web.UI.MasterPage, IMasterPage{

    #region ImasterPage Members

     public void Set Selected(string name){
    
    
    
      switch (name){
    
    
       case "gtm": this.gtm.CssClass = "gtm_sel"; break;
    
    
       default: break;
    
    
      }
    
    }

    }

the codes shown are for the horizontal, single-level main menu somewhere on top of page and i wanted the menu selected to highlight after the page reloads but the page_load on the page1.aspx does not seem to be called! this is the part of the menu in the masterpage:

<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>

all css styles for hover and selected (eg: gtm_sel) are defined and working properly in the sense that when i bypass the page load even from page1.aspx onto the page_load event of the master page calling it from there like: this.SetSelected('gtm'); it works like a charm

haywired.

A: 

Do you have AutoEventWireup="true" in the Page directive...

<%@ Page Language="C#" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>
Greg B
yes i do have it set to true..
jan