unable to get type of control for radcombobox in javascript

a 夏天 提交于 2019-12-12 03:29:35

问题


I am new to radcontrols. I want to know how to get type of control of a radcontrol using javascript. For normal asp.net controls we write:

 var controlType=document.getElementById("hdnCode").type;

The above code will give type of control as "hidden", and for textbox it will give "text".

When i try to get type of a rad control it gives undefined as shown here:

 var controlType=document.getElementById("RadComboBox1").type;

The above code gives undefined.

Please suggest me how to get type in case of Rad Controls.

Thanks


回答1:


You can't really check for the type of the control like this, these are complex objects (IScriptControls) and not simple HTML elements.

You can try the following approach to see the instances of given type (the if block shows how you can make a check only):

function get_allRadCombos()
        {
            var allRadCombos = [];
            var allRadControls = $telerik.radControls;
            // all RadControls are referenced

            for (var i = 0; i < allRadControls.length; i++)
            {
                var element = allRadControls[i];

                if (Telerik.Web.UI.RadComboBox && Telerik.Web.UI.RadComboBox.isInstanceOfType(element))
                {
                    allRadCombos.push(element);
                }
            }
            // only the RadCombos are gathered into an array
            return allRadCombos;
        }

The $telerik.radControls is an array the RadControls create and populate, you can check a given instance by referencing it through the $find(controlClientID) method



来源:https://stackoverflow.com/questions/16212730/unable-to-get-type-of-control-for-radcombobox-in-javascript

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