March 1, 2012

$find returning null

Question by Dhaval Shukla

I have radGrid in .ascx page in which I want to find the control using $find but it returns a null to me. Below is my code which I am using to get the object (written in .ascx).

<script type="text/javascript">
    $(function () {
        var Rates_gridID = $find('<%= gridRates.ClientID %>');
        alert(Rates_gridID);
    });
</script>

Here, I am getting Rates_gridID as null in alert. Interesting thing which I noted is when I change the jQuery version to 1.2.6 from 1.6.4 I am getting Rates_gridID object. I have googled this a lot but not getting any solution. I think the problem is with $(function().

Answer by Starx

You are using the incorrect syntax. Try

$("body").find('<%= gridRates.ClientID %>');

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!