Select menu item on page load

4 posts, 0 answers
  1. Charles Meyer
    Charles Meyer avatar
    4 posts
    Member since:
    Feb 2008

    Posted 08 Feb 2008 Link to this post

    Can anyone tell me how to "select" the first RadMenuItem on the page load event? I have the following menu code and want the first item to appear as if it had been clicked (highlighted)

    <

    telerik:RadMenu ID="rmSubMenu" runat="server" Flow="Horizontal" Skin="Inox" Width="100%">
        <DefaultGroupSettings ExpandDirection="Auto" Flow="Vertical" />
        <CollapseAnimation Duration="200" Type="OutQuint" />
        <Items>
        
        <
    telerik:RadMenuItem runat="server" ExpandMode="ClientSide" Text="Create Mission" ToolTip="Create a new mission">
        <GroupSettings ExpandDirection="Auto" Flow="Vertical" />
        </telerik:RadMenuItem>

        <
    telerik:RadMenuItem runat="server" ExpandMode="ClientSide" Text="Edit Missions" ToolTip="Edit existing missions">
        <GroupSettings ExpandDirection="Auto" Flow="Vertical" />
        </telerik:RadMenuItem>

        </Items>
        <ExpandAnimation Type="OutQuart" />
    </
    telerik:RadMenu>

  2. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 11 Feb 2008 Link to this post

    Hello Charles,

    One possible solution is the following:
    protected void Page_Load(object sender, EventArgs e)  
        {  
            if (!IsPostBack)  
            {  
                rmSubMenu.Items[0].CssClass = "rmFocused";          
            }          
        } 

    Feel free to contact us if you have additional questions.


    Best wishes,
    Peter
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Charles Meyer
    Charles Meyer avatar
    4 posts
    Member since:
    Feb 2008

    Posted 11 Feb 2008 Link to this post

    Peter,

    That "worked", but left the first menu item as always selected. I have made it work, and have included the code for others to view. Please let me know if there is a better way of doing this.

    protected

    void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            rmSubMenu.Items[0].CssClass =
    "rmFocused";
        }
    }

    protected void rmSubMenu_ItemClick(object sender, Telerik.Web.UI.RadMenuEventArgs e)
    {
         rmSubMenu.Items[0].CssClass =
    "";
         rmSubMenu.Items[1].CssClass =
    "";

        ..... Some code here.....

        rmSubMenu.Items[e.Item.Index].CssClass =

    "rmFocused";
    }

  4. Peter
    Admin
    Peter avatar
    6637 posts

    Posted 14 Feb 2008 Link to this post

    Hello Charles,

    Yes, this is one possible way to achieve the show path functionality. However, there is a more dynamic solution which handles both the case when clicking on an item redirects to another page and when the click action causes only a postback. Please, refer to this code library project, which I updated recently:

    http://www.telerik.com/community/code-library/submission/b311D-egktk.aspx

    Feel free to let us know if you have any questions.


    Greetings,
    Peter
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top