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

$find doesn't find

6 Answers 240 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andrea Ferlito
Top achievements
Rank 1
Andrea Ferlito asked on 19 May 2010, 06:53 PM
Hello everybody.
I can't succed in find anything with $find('objectID') method.
I'm using a webapp structure consisting of one page that loads dynamically a couple of UserControls implementing various functions.
On the other hand document.getElementById('objectID') give me back the object, so I'm pretty sure the objectID is correct.
Any idea?

Thanks in advance

Andrea

6 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 20 May 2010, 10:55 AM
Hello Andrea,

If you want to get reference to the html element you should use $get. The $find method should be used when a instance of Sys.Component need to be find.

Regards,
Rosen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Andrea Ferlito
Top achievements
Rank 1
answered on 20 May 2010, 03:18 PM
Thank you for your answer Rosen.
But my prolem is that I need to get a RadCalendar client object in order to select the date.
$find returns always null, $get and getElementById instead return the correct HTML object.
Don't know if it's necessary to include some js specific file.

0
Rosen
Telerik team
answered on 25 May 2010, 09:13 AM
Hello Andrea,

You should ensure that you are using control's ClientID.
Also can you please paste (using format code block button) the code your are trying to use and page's declaration here?

All the best,
Rosen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Adham Shaaban
Top achievements
Rank 1
answered on 18 Jan 2011, 12:34 AM
I'm having this same exact issue.  What I'm trying to do is (or should be!) very simple, get a handle to a RadInput (RadNumericTextBox) control so I can get its value and assign it to another RadInput control.  I saw several posts on the forums regarding loading the scripts at the right time, etc. but this doesn't apply here since I'm not running this at page load, it's a handler for the OnValueChanged event for the control so will only run after the whole page has loaded.  Like the OP's scenario, $get and getElementById both work so I know there are no issues with the control ID itself, just with $find.  Here's my script code (placed within a Content control for a page that uses a MasterPage, the ScriptManager control is on the MasterPage):

<script language="javascript" type="text/javascript">
    function Test(sender, eventArgs) {
        var marketRecoveryHours = $find('<%= txtMarketRecoveryHours.ClientID %>');
        alert(marketRecoveryHours); // just to test, this always returns null!
    }
</script>

Here's the control definition (further down within the Content control):
<radI:RadNumericTextBox ID="txtMarketRecoveryHours" runat="server" CssClass="shortTextBox"
Culture="English (United States)" LabelCssClass="radLabelCss_Default" Skin="" 
Type="Number" Text="0" Value="0" ClientEvents-OnValueChanged="Test">
</radI:RadNumericTextBox>

I've also tried wrapping that script block in RadCodeBlock and RadScriptBlock tags per one of the other forum messages but none of these solutions work. The $find method fails in both IE8 and FF3.6  Any help would be appreciated.

thanks,
Adham

0
Iana Tsolova
Telerik team
answered on 18 Jan 2011, 02:43 PM
Hello Adham,

Can you try modifying your script as below and see if it works:

<script language="javascript" type="text/javascript"
    function Test(sender, eventArgs) { 
        var marketRecoveryHours = sender; 
        alert(marketRecoveryHours); // just to test, this always returns null!
    
</script>


Additionally, could you please confirm you are using RadNumericTextBox for ASP.NET AJAX but RadNumericTextBox for ASP.NET?

Best wishes,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Adham Shaaban
Top achievements
Rank 1
answered on 18 Jan 2011, 09:27 PM
That was it!  That app still had some legacy RadControls on some of the pages and that numeric textbox was one of them.  I updated it to the proper 2009 Q2 version that I'm using and it works now.  I don't know how I missed that old <radI> tag.  Thanks Iana!
Tags
General Discussions
Asked by
Andrea Ferlito
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Andrea Ferlito
Top achievements
Rank 1
Adham Shaaban
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or