telerik RadComboBox find Returns null - why?

主宰稳场 提交于 2019-12-11 12:41:49

问题


why the below javascript code always returns null (mean alert) ?

<%@ 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>

thanks in future advace best regards


回答1:


try:

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

Certain scripts need to run/load first before $find will work.



来源:https://stackoverflow.com/questions/4069145/telerik-radcombobox-find-returns-null-why

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!