How to Hide and Change Menu item Text in Master Page from Content Pages Page load event

2 posts, 0 answers
  1. gc_0620
    gc_0620 avatar
    191 posts
    Member since:
    Feb 2008

    Posted 01 Oct 2009 Link to this post

    Hi there.

    Environment: I am using Radcontrols for ASP.NET AJAX Q2 2009 SP1 with VStudio 2008 SP1.

    I have a Rad Menu in Master Page with 3 Navigate Url's. Below are Master page Rad menu and 3 content pages.

    I would like to do the following:

    1) In the page load event of (
    ContentPage1_for_MasterPage1), hide the Rad Menu Item#1 in Master Page.
    (i.e hide this menu:  
    <telerik:RadMenuItem Text="Go to ContentPage2_for_MasterPage1.aspx" NavigateUrl="~/ContentPage2_for_MasterPage1.aspx" >).

     

    2) In the page load event of (ContentPage1_for_MasterPage1), Change Menu Item# 2 Text in Master page
    (i.e Change this Menu Item (
    <telerik:RadMenuItem Text="Go to ContentPage3_for_MasterPage1.aspx" NavigateUrl="~/ContentPage3_for_MasterPage1.aspx>)  Text to: “I am using Telerik Rad Controls”.

     

    I know how to hide the Rad Menu Item in current page but just don’t know how to hide/change from
    Content->Master Page. That’s what I am doing in current page:

     

    protected void Page_Load(object sender, EventArgs e)

        {

           RadMenu1.FindItemByText("Go to ContentPage2_for_MasterPage1.aspx").Visible = false;

       

        }


    Any Help will be appreciated. Thanks
     
    Gc_0620
    ____________

    Rad Menu in Master Page:

     

    <telerik:RadMenu runat="server" ID="RadMenu1" Style="float: none; left: 0px; height: 20px; width:100%"

           Skin="Office2007">

                      <Items>

                            <telerik:RadMenuItem Text="MasterPage1 Test Menu">

                            <Items>

                                <telerik:RadMenuItem Text="Go To ContentPage1_for_MasterPage1.aspx" NavigateUrl="~/ContentPage1_for_MasterPage1.aspx">

                                </telerik:RadMenuItem>

                                <telerik:RadMenuItem Text="Go to ContentPage2_for_MasterPage1.aspx" NavigateUrl="~/ContentPage2_for_MasterPage1.aspx">

                                </telerik:RadMenuItem>

                                  <telerik:RadMenuItem Text="Go to ContentPage3_for_MasterPage1.aspx" NavigateUrl="~/ContentPage3_for_MasterPage1.aspx">

                                </telerik:RadMenuItem>

                            </Items>

                        </telerik:RadMenuItem>

                      </Items>

                </telerik:RadMenu>


    Content Page1:

     

    <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage1.master" AutoEventWireup="true" CodeFile="ContentPage1_for_MasterPage1.aspx.cs" Inherits="ContentPage1_for_MasterPage1" %>

     

    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

    </asp:Content>

    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    You are in ContentPage1_for_MasterPage1.aspx..

    </asp:Content>


    Content Page2:


    <%
    @ Page Title="" Language="C#" MasterPageFile="~/MasterPage1.master" AutoEventWireup="true" CodeFile="ContentPage2_for_MasterPage1.aspx.cs" Inherits="ContentPage2_for_MasterPage1" %>

     

    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

    </asp:Content>

    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    You are in ContentPage2_for_MasterPage1.aspx..

    </asp:Content>

     

    Content Page3:

     

    <%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage1.master" AutoEventWireup="true" CodeFile="ContentPage3_for_MasterPage1.aspx.cs" Inherits="ContentPage3_for_MasterPage1" %>

     

    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

    </asp:Content>

    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

    You are in ContentPage3_for_MasterPage1.aspx..

    </asp:Content>

     

  2. gc_0620
    gc_0620 avatar
    191 posts
    Member since:
    Feb 2008

    Posted 02 Oct 2009 Link to this post

     Never mind folks...

    I solved the issue. In ContentPage1_for_MasterPage1 Page Load event I did this. It works...


    protected
    void Page_Load(object sender, EventArgs e)

        {

            RadMenu mastermenu = (RadMenu)Master.FindControl("RadMenu1");

            mastermenu.FindItemByText("Go to ContentPage2_for_MasterPage1.aspx").Visible = false;

            mastermenu.FindItemByText("Go to ContentPage3_for_MasterPage1.aspx").Text = "I am using Telerik Rad Controls";

                }

    Thanks

    gc_0620

  3. DevCraft Release
Back to Top