Jake Gearhart Jake Gearhart - 20 days ago 7
ASP.NET (C#) Question

$find returning null when retrieving telerik controls in javascript

I am trying to write a javascript function to show and hide a telerik:RadAjaxLoadingPanel, but for some reason when I try to use the $find function it always comes back as null even after the controls are loaded.

I am new to asp.net development can someone tell me what is going wrong?

My telerik control .aspx code

<telerik:RadAjaxLoadingPanel ID="ModalLoadingPanel" runat="server" Transparency="10" BackColor="#E0E0E0" Modal="true">
<div style="margin-left: auto; margin-right: auto; margin-top: 45px; margin-bottom: auto; width: 135px; height: 80px;"
class="modalProgress">
<div class="spinner"></div>
</div>
</telerik:RadAjaxLoadingPanel>


My javascript function that exists in a tag

function showActivityIndicator() {
var loadingPanel = $find("<%= ModalLoadingPanel.ClientID %>");
loadingPanel.set_modal(true);
}


Thanks!

Answer

Try

$("#<%= ModalLoadingPanel.ClientID %>").find();

$ is a function which takes a selector and if the selector is an ID it should be prepended with # sign.

Actually you don't even need find unless you need to do further filtration. So this will get you the tag:

$("#<%= ModalLoadingPanel.ClientID %>");
Comments