Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get Kendo().TextBoxFor value in javascript?

I'm using Kendo UI TextBoxFor such as:

@Html.Kendo().TextBoxFor(model => model.ID).HtmlAttributes(new {  @class = "fixed-width" }).Name("ID")

but I am unable to fetch the value in javascript:

var id = ????

any help is appreciated, thanks.

like image 406
J09 Avatar asked Dec 27 '16 05:12

J09


2 Answers

A TextBox used with @(Html.Kendo().TextBox() or @(Html.Kendo().TextBoxFor(m => m.Property) is just a helper method to create an input field. You can use jquery to get all fields with $('.k-textbox').

You may also add an id to get specific text boxes:

@(Html.Kendo().TextBoxFor(m => m.Property)
   .HtmlAttributes(new
   {
       id = "text-box-property-id"
   })
)

To get the value on client side with Javascript you could use jquery.

$('#text-box-property-id').val()
like image 186
Marcel Melzig Avatar answered Oct 31 '22 12:10

Marcel Melzig


you can retrieve the value this way using JQuery:

$('#ID').data('kendoTextBox').value();
like image 20
CommonPlane Avatar answered Oct 31 '22 11:10

CommonPlane