telerik RadComboBox查找返回null - 为什么?

问题描述:

为什么下面的JavaScript代码总是返回空(平均值警报)?telerik RadComboBox查找返回null - 为什么?

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication3.WebForm1" %> 

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head id="Head1" runat="server"> 
    <title></title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> 
    </telerik:RadScriptManager> 
    <div> 
     <telerik:RadComboBox ID="RadComboBox1" runat="server"> 
     </telerik:RadComboBox> 
    </div> 
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> 
     <script type="text/javascript"> 
      var combo = $find("<%= RadComboBox1.ClientID %>"); 
      alert(combo); 
     </script> 
    </telerik:RadCodeBlock> 
    </form> 
</body> 
</html> 

感谢在未来advace 问候

尝试:

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> 
    <script type="text/javascript"> 
     function pageLoad() { 
      var combo = $find("<%= RadComboBox1.ClientID %>"); 
      alert(combo); 
     } 
    </script> 
</telerik:RadCodeBlock> 

某些脚本需要运行/加载之前先找到$将工作。

+6

哪些脚本? – CRice 2011-12-16 01:40:12