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

[Solved] get_value() not returning the value

1 Answer 440 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Michael Pullella
Top achievements
Rank 1
Michael Pullella asked on 27 Jan 2010, 04:28 PM

Hello
I am filling my combobox with data in this manner (I can see the DataTextField)

 

            EntityType[] entityTypes = WritingPresenter.GetEntityTypes();  
              
            this.ddlType.DataSource = entityTypes;  
            this.ddlType.DataTextField = "Type";  
            this.ddlType.DataValueField = "GUID";  
              
            this.ddlType.DataBind();  
 


I am trying to retrieve the selectedvalue via Javascript by doing this:

 

        var combo = <%=ddlType.ClientID %>;  
        returnVals.type = combo.get_value();   
 

However, when the javascript runs, I get a Microsoft JScript runtime error: Object doesn't support this property or method when it tries to get the value.

Interestingly, if I look at the html that gets generated, I do not see the dataValue:
<div class="rcbSlide" style="z-index:6000;">  
    <div id="ddlType_DropDown" class="RadComboBoxDropDown RadComboBoxDropDown_Default " style="float:left;display:none;">  
        <div class="rcbScroll rcbWidth" style="width:100%;">
            
<ul class="rcbList" style="list-style:none;margin:0;padding:0;zoom:1;">  
                <li class="rcbItem ">Passport</li> 
                <li class="rcbItem ">Individual</li>
            
</ul>  
        </div> 
    </div>     
</div> 
 
<input id="ddlType_ClientState" name="ddlType_ClientState" type="hidden" /> 

Here is the markup from the aspx page:
                    <telerik:RadComboBox ID="ddlType" runat="server" Width="100%">  
                    </telerik:RadComboBox> 
 

Do I need a few more properties on my RadComboBox to get this working?

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 28 Jan 2010, 05:31 AM
Hi Michael,

You have to use $find() method in order to access the client side object of RadComboBox.
          var combo = $find("<%= RadComboBox1.ClientID %>");

Use the following client code for getting the vaue from client.
JavaScript:
 
    function getvalue() { 
          var combo = $find('<%=ddlType.ClientID %>'); 
          alert(combo.get_value()); 
    } 

Also checkout the following:
Client-Side Basics

-Shinu.
Tags
ComboBox
Asked by
Michael Pullella
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or