DropDownList Value returned 'Undefined'

2 posts, 1 answers
  1. Khem
    Khem avatar
    2 posts
    Member since:
    Mar 2012

    Posted 18 Apr 2013 Link to this post

    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 ??

  2. Answer
    Khem
    Khem avatar
    2 posts
    Member since:
    Mar 2012

    Posted 18 Apr 2013 Link to this post

    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
Back to Top