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

DropDownList Value returned 'Undefined'

1 Answer 147 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Khem
Top achievements
Rank 1
Khem asked on 18 Apr 2013, 05:30 AM
Hi,
While retrieving the value of dropdownlist I am getting 'undefined'. here is my code: 

 @(Html.Telerik().DropDownList()
          .Name("cmbInvoieNo")
          .BindTo(new SelectList(Model.PIModel, "InvoiceID", "InvoiceName"))
                   .Placeholder("Select Invoice Number...")
                   .HtmlAttributes(new { style = "width: 230px; float: left;" })
                                    ) 
 <div><button type="submit" class="t-button t-state-default" onclick="getInvoiceNo()"> @Model.ButtonCaption</button> </div>
----------------------------------------------------------------------------------------------
@{
    <script type="text/javascript">
              function getInvoiceNo() {
            var cmbInvoice = $("#cmbInvoieNo").data("tDropDownList").text();            
            alert(" Invoice1 : " + cmbInvoice);
        }      
   </script>
}

--- On Click of 'Submit' button : $("#cmbInvoieNo").data("tDropDownList").text() return 'undefined' 
$("#cmbInvoieNo") ---  'defined'
$("#cmbInvoieNo").data("tDropDownList") ------- undefined

any Idea what could be wrong ??

1 Answer, 1 is accepted

Sort by
0
Accepted
Khem
Top achievements
Rank 1
answered on 18 Apr 2013, 05:57 AM
I just closed my solution and restarted VS, and It got resolved ..may be some caching issue... not sure..... but now its working fine.

Thanks
Khem
Tags
DropDownList
Asked by
Khem
Top achievements
Rank 1
Answers by
Khem
Top achievements
Rank 1
Share this question
or