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

NumericTextBox does not submit the form after changing values

3 Answers 457 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
Alberto
Top achievements
Rank 1
Alberto asked on 30 Dec 2019, 09:13 AM

I'm converting a legacy form to Telerik UI, DropDownListForm "onchange" event works without changing anything while the NumericTextBoxFor "change" and "spin" events don't work, do you know why? Here is the relevant source code of my view:

<div class="form-group">
              @Html.LabelFor(m=>m.Quantity, new { @class = "col-md-3 control-label" })
              <div class="col-md-4">
                  @*@Html.TextBox("quantity", Session["quantity"].ToString(), new { @class = "form-control", onchange = "this.form.submit();" })*@
                 
              @(Html.Kendo().NumericTextBoxFor(model=>model.Quantity).Decimals(2).Format("n0").HtmlAttributes(new { style = "width: 100%", @class = "form-control", change = "this.form.submit();", spin = "this.form.submit();"}))
              </div>
          </div>
 
          <div class="form-group">
              @Html.LabelFor(m=>m.SelectedYear, new { @class = "col-md-3 control-label" })
              <div class="col-md-4">
                  @*@Html.DropDownList("numYears", (List<SelectListItem>)ViewBag.PossibleYears, new { @class = "form-control", onchange = "this.form.submit();" })*@
 
                  @(Html.Kendo().DropDownListFor(model => model.SelectedYear).BindTo(Model.YearList).HtmlAttributes(new { style = "width: 100%", @class = "form-control", onchange = "this.form.submit();" }))
              </div>
          </div>

3 Answers, 1 is accepted

Sort by
0
Tsvetomir
Telerik team
answered on 31 Dec 2019, 01:36 PM

Hi Alberto,

The Kendo UI NumericTextBox utilizes two distinct input elements. Therefore, attaching a change event via the attributes might not get called. What I can recommend is that you attach it via the options of the widget:

.Events(ev=>ev.Change("onChange"))

function onChange(e){
      // ....
}

I hope this helps.

 

Regards,
Tsvetomir
Progress Telerik

Get quickly onboarded and successful with your Telerik UI for ASP.NET MVC with the dedicated Virtual Classroom technical training, available to all active customers.
0
Alberto
Top achievements
Rank 1
answered on 31 Dec 2019, 01:48 PM

Thanks Tsvetomir,

what I need to write inside the onChange(e) javascript function to submit the form?

Alberto

0
Accepted
Tsvetomir
Telerik team
answered on 02 Jan 2020, 08:22 AM

Hi Alberto,

I suspect that the form has an id set. You could access it with the help of jQuery and programmatically submit the form. Here is an example:

$("#formID").submit();

Give this a try and let me know how it works out for you.

 

Regards,
Tsvetomir
Progress Telerik

Get quickly onboarded and successful with your Telerik UI for ASP.NET MVC with the dedicated Virtual Classroom technical training, available to all active customers.
Tags
NumericTextBox
Asked by
Alberto
Top achievements
Rank 1
Answers by
Tsvetomir
Telerik team
Alberto
Top achievements
Rank 1
Share this question
or