This is a migrated thread and some comments may be shown as answers.

Select menu item on page load

3 Answers 194 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Charles Meyer
Top achievements
Rank 1
Charles Meyer asked on 08 Feb 2008, 06:44 PM

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>

3 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 11 Feb 2008, 04:13 PM
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
0
Charles Meyer
Top achievements
Rank 1
answered on 11 Feb 2008, 07:21 PM
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";
}

0
Peter
Telerik team
answered on 14 Feb 2008, 09:54 AM
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
Tags
Menu
Asked by
Charles Meyer
Top achievements
Rank 1
Answers by
Peter
Telerik team
Charles Meyer
Top achievements
Rank 1
Share this question
or