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

RadMenu $find not working

1 Answer 173 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Gibson Wong
Top achievements
Rank 1
Gibson Wong asked on 30 Jun 2010, 04:50 PM
UPDATE: I've found the problem.
I can't $find the RadMenu control until page is done rendering. 
================================================================
Hello, I'm having trouble with using $find in client-side javascript to get a reference of a RadMenu
$find returns null while $get returns an object.
However, the object $get returned doesn't support .findItemByValue() method.
I'm using Q1 2010 Net4 version with VS2010 and web.config set to .NET 4.

I've also tried $find("RadMenu1");

What kind of dependencies are there for RadMenu? web.config settings?
Thanks.
Gibson

See code below:

var menu = $find("RadMenu1"); 
var item = menu.findItemByText("Message Center"); 
 

1 Answer, 1 is accepted

Sort by
0
Krishnaprabhuraja
Top achievements
Rank 1
answered on 01 Jul 2010, 12:18 PM

The $get is shorthand for the document.getElementById and element.getElementById functions. The $find is shortcut function for Sys.Application.findComponent which allows you to look up an ASP.NET AJAX client side Component. So basically you need to use $find to get reference to RadMenu client side Component.

The $find is useful only when all client script has been loaded and initialized. Typically you can write a global function named pageLoad (see below code snippet) or you can explicitly subscribe to the load event of the Application class for client side initialization.

<script type="text/javascript">         
    function pageLoad() {     
       // Initialization code here, meant to run once.      
       // Note: Unsuitable if used with UpdatePanels.     
        var menu = $find("RadMenu1");     
        var item = menu.findItemByText("Message Center");     
    }      
</script>    
 


Regards,
Krishna

Tags
Menu
Asked by
Gibson Wong
Top achievements
Rank 1
Answers by
Krishnaprabhuraja
Top achievements
Rank 1
Share this question
or