This is a migrated thread and some comments may be shown as answers.

ClientSide API - what am I missing

8 Answers 190 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Guss
Top achievements
Rank 2
Guss asked on 24 May 2008, 10:34 AM
Hi there
I don't seem to get clientside stuff to work. What am I missing? (still running under trial)

Here is mu code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %> 
 
<%@ 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 runat="server"
    <title>Untitled Page</title> 
</head> 
<body> 
    <form id="form1" runat="server"
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
    </telerik:RadScriptManager> 
    <div> 
        <telerik:RadComboBox ID="RadComboBox1" runat="server" DataSourceID="SqlDataSource1" 
            DataTextField="Text" DataValueField="Value" Skin="Vista"
            <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
        </telerik:RadComboBox> 
         
        <script type="text/javascript" language="javascript" > 
        var combo = <%=RadComboBox1.ClientID %>
        var projectId = combo.GetText(); 
        alert(projectId); 
        </script> 
 
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:RemoteSqlServerData %>" 
            SelectCommand="SELECT [value], [text] FROM [vProject]"></asp:SqlDataSource> 
 
    </div> 
    </form> 
</body> 
</html> 
 

It throws and error at combo.GetText();
Microsoft JScript runtime error: Object doesn't support this property or method

For the dynamixc content, it did resolve <%=...ClientId%>
        var combo = RadComboBox1;
        var projectId = combo.GetText();

when I do an alert(combo); it does return [object]..so I assume it worked correct up to here.

8 Answers, 1 is accepted

Sort by
0
Rosi
Telerik team
answered on 26 May 2008, 10:21 AM
Hi Guss,

I suggest you use get_text() instead of GetText().

Please read our help article - RadComboBox Object  and have a look at our online example -Client Side API.


Regards,
Rosi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Guss
Top achievements
Rank 2
answered on 26 May 2008, 02:48 PM
I do not understand, its still not working.

get_text(), get_value() all return the same error............
Microsoft JScript runtime error: Object doesn't support this property or method.

It is as if NO client side API stuff is working....!

Replacing <%=RadComboBox1.ClientID %> with $find(<%=RadComboBox1.ClientID%>) even make things worse.

Using the $find throws this err: Microsoft JScript runtime error: Sys.ArgumentTypeException: Object of type 'Object' cannot be converted to type 'String'. from the function Sys$_Application$findComponent.



0
Atanas Korchev
Telerik team
answered on 26 May 2008, 03:38 PM
Hello Guss,

The id of the combobox should be quoted when passed to the $find method as it expects a string:

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

Sincerely yours,
Albert
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Guss
Top achievements
Rank 2
answered on 26 May 2008, 07:38 PM
Now when I do that I get
Microsoft JScript runtime error: 'null' is null or not an object, so $find didn't find the object.
I'm sure the error is caused by more than syntax.

Its like every client side event is not working.

take this example: it causing the same error.

<telerik:RadTreeView ID="RadTreeView1" runat="server" CheckBoxes="true">
<Nodes>
<telerik:RadTreeNode runat="server" Text="Node1">
<Nodes>
<telerik:RadTreeNode runat="server" Text="Node1.1">
</telerik:RadTreeNode>
</Nodes>
</telerik:RadTreeNode>
<telerik:RadTreeNode runat="server" Text="Node2">
<Nodes>
<telerik:RadTreeNode runat="server" Text="Node2.1">
</telerik:RadTreeNode>
<telerik:RadTreeNode runat="server" Text="Node2.2">
</telerik:RadTreeNode>
</Nodes>
</telerik:RadTreeNode>
</Nodes>
<CollapseAnimation Type="OutQuint" Duration="100"></CollapseAnimation>
<ExpandAnimation Duration="100"></ExpandAnimation>
</telerik:RadTreeView>

<script type="text/javascript" language="javascript">
var treeView = $find("<%=RadTreeView1.ClientID%>");
var selectedNode = treeView.get_selectedNode();
</script>

(Microsoft JScript runtime error: 'null' is null or not an object)

0
Guss
Top achievements
Rank 2
answered on 26 May 2008, 08:01 PM
PS: Where is all this javascript API files?
Is it the files in RadControls for ASPNET AJAX Q1 2008\Scripts?

If this files has an influence, how does my webapp know to use these files, as in my bin directory is these files Telerik.Charting.dll, Telerik.Charting.xml, Telerik.Web.UI.dll, Telerik.Web.UI.xml.

I'm not using the GAC, the dll is in my bin folder. Should all the ASPNET AJAX Q1 2008\Scripts be copied somewhere locally for the clientside API to work?

0
Accepted
Rosi
Telerik team
answered on 27 May 2008, 05:22 AM
Hi Guss,

I suggest you execute the following javascript code in pageLoad event of the page.

For example:
<script type="text/javascript" language="javascript">   
 
function pageLoad()  
{  
   var treeView = $find("<%=RadTreeView1.ClientID%>");   
   var selectedNode = treeView.get_selectedNode();   
 
}  
</script> 
Before pageLoad is executed, RadControls for  ASP.NET AJAX are still not loaded completely and ready to use. This is the reason for the error you received.

Also note that the script of the controls are loaded from web resources and you do not need to copy any folders.

If the problems still persist, please open a support ticket and send us a simple running project illustrating them so we can test it locally.

Regards,
Rosi
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Guss
Top achievements
Rank 2
answered on 27 May 2008, 07:25 AM
You right. the functions was not available at the time I called it. It is a bit more complex because of the master pages I use, but I registered the javascript block in my code-behind on pagelaod, and viola, it worked. this.RegisterStartupScript("Startup", strjsscript);

Thank you for the support.


0
Oswaldo Huezo
Top achievements
Rank 1
answered on 14 Jul 2008, 08:43 PM
Hi all,

I have a radcombobox and I have .js file that I included to reference all the client side functions.  My problem is that  I can't seem to be able to find a button I need to focus after the user has selected an item from the combobox.

I tried

function OnClientSelectedIndexChanged(item)
 {
            //var mybutton = $find("<%=btnFiltrar.ClientID %>");
            //mybutton.focus();
           
           //document.getElementByID(<%=btnFiltrar.ClientID %>).focus();
 }

But none of the two things above worked.  How should I reference the button so I can focus it right after I have chosen an item? Thanks in advance.
Tags
ComboBox
Asked by
Guss
Top achievements
Rank 2
Answers by
Rosi
Telerik team
Guss
Top achievements
Rank 2
Atanas Korchev
Telerik team
Oswaldo Huezo
Top achievements
Rank 1
Share this question
or