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

[Solved] Set focus on page load

3 Answers 165 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Nancy
Top achievements
Rank 1
Nancy asked on 20 May 2009, 10:41 PM
I need to set the focus (selected menu item) on page load and can't figure out how to do it correctly. In code behind I tried

this.RadMenu1.Items[0].CssClass = "rmFocused";

 and that works but it never loses focus no matter which menu items are clicked. I can't figure out how to make it lose focus when another menu item is clicked. I tried a client side event to set the CssClass and it does not work, nor does item.focus() - can't get any client side event to make it focused on loading. Seems a very simple task I want to do - just focus the darn item onload and take focus off when another item selected - simple eh? lol

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 May 2009, 06:11 AM
Hello Nancy,

You can try out the following code to change the focus from the menu item on selecting another menu item:
c#:
protected void Page_Load(object sender, EventArgs e) 
    { 
        if (!IsPostBack) 
        { 
            RadMenu1.Items[0].CssClass = "rmFocused"
        } 
        else 
        { 
            RadMenu1.Items[0].CssClass = ""
        } 
    } 

Thanks
Princy.
0
Nancy
Top achievements
Rank 1
answered on 21 May 2009, 03:37 PM
Already tried that. Problem is there is not a postback to code behind when click on the menu items - they are URLs with target to  splitter so no postback. That's why I tried clientside events - tried to set the cssClass on clientside but it does nothing.
0
Conrad
Top achievements
Rank 1
answered on 01 Jun 2009, 08:55 PM
Haven't used the spliiter control yet, but when using master pages, I use the following:

CType

 

(Master.FindControl("radmenu1"), Telerik.Web.UI.RadMenu).Items(0).CssClass = "rmFocused"

 

Tags
Menu
Asked by
Nancy
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Nancy
Top achievements
Rank 1
Conrad
Top achievements
Rank 1
Share this question
or