How to acces control from masterpage

Last post 09-10-2006 12:11 PM by joteke. 4 replies.

Sort Posts:

  • How to acces control from masterpage

    09-05-2006, 8:33 AM
    • Member
      40 point Member
    • FrankBeerens
    • Member since 08-18-2006, 7:14 PM
    • Posts 8

    Hello i have a dropdownlist on my masterpage.

    But how can i select the index of that dropdownlist from my content ?

    I thought to add the index to a session but de page load event is done before the index changed event ?

     

  • Re: How to acces control from masterpage

    09-05-2006, 11:58 AM
    Answer
    • All-Star
      46,040 point All-Star
    • joteke
    • Member since 06-16-2002, 3:24 PM
    • Kyro, Finland
    • Posts 6,879
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs

    You can locate the DropDownList by running Master.FindControl

    Dim ddl As DropDownList = DirectCast(Master.FindControl("DropDownList1"), DropDownList)
    ddl.SelectedIndex = 3

    Postback events are always raised after Page_Load.

    Thanks,

    Teemu Keiski
    Finland, EU
  • Re: How to acces control from masterpage

    09-10-2006, 12:14 AM
    • All-Star
      22,266 point All-Star
    • vik20000in
    • Member since 12-30-2005, 6:02 AM
    • Kolkata
    • Posts 3,464
    • TrustedFriends-MVPs

    You can alos create a property in the master page and acess it through the content page. More OOP.

    Vikram

    Vikram's Blog

    Vikram
    www.vikramlakhotia.com


    Please mark the answer if it helped you
  • Re: How to acces control from masterpage

    09-10-2006, 1:33 AM
    • Member
      131 point Member
    • Paul44
    • Member since 05-13-2006, 3:58 PM
    • Posts 50

    Can you expand on the   property in the master page   I have a master page that contains:

    <div id="mainmenu">
       <ul>
           <li><a href="<%=Page.ResolveUrl("~/default.aspx")%>" id="tab_Home" class="selected">Home</a></li>
           <li><a href="http://forums.asp.net/AddPost.aspx?PostID=1388327#" id="tab_Services">Services</a></li>
           <li><a href="http://forums.asp.net/AddPost.aspx?PostID=1388327#" id="tab_Contact">Contact</a></li>
           <li><a href="<%=Page.ResolveUrl("~/About.aspx")%>" id="tab_About">About</a></li>
           <li><a href="<%=Page.ResolveUrl("~/AboutSelected.aspx")%>" id="tab_AboutSelected" class="selected">AboutSelected</a></li>
                    <%if(Page.User.IsInRole("Administrator")){ %>
            <li><a href="<%=Page.ResolveUrl("~/admin") %>" id="tab_Admin">Admin</a></li>
                  <%} %>
       </ul>
    </div>

    The tab_Home is set for  class="selected"  (the default page) and when another tab is clicked I would like to know how to set the Master Page "class" for the tab_Home to not-selected???  and then set the appropriate tab to  "selected"

    Something like  Master.mainmenu.tab_Home.selected=""   and then

                            Master.mainmenu.tab_About.selected="selected"   in the Page_Load of the About page...

    This will (I hope) move the Highlight from the tab_Home tab to the tab_About tab...

    Can you please tell me how to do this in C# 

    Thanks,

    Paul

     

     

     

  • Re: How to acces control from masterpage

    09-10-2006, 12:11 PM
    • All-Star
      46,040 point All-Star
    • joteke
    • Member since 06-16-2002, 3:24 PM
    • Kyro, Finland
    • Posts 6,879
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs

    You find an example in following post:
    http://forums.asp.net/thread/1168780.aspx

    And see also a good reference article: http://www.codeguru.com/csharp/.net/net_asp/webforms/article.php/c11303/

    Thanks,

    Teemu Keiski
    Finland, EU
Page 1 of 1 (5 items)