Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > NumericTextBox > IntegerTextBoxFor: value displayed upon resetForm() vs. focus

Answered IntegerTextBoxFor: value displayed upon resetForm() vs. focus

Feed from this thread
  • Luke avatar

    Posted on Jun 8, 2011 (permalink)

    Hello,

    I am currently using an IntegerTextBoxFor in a form. The form has a cancel button which calls resetForm() (actually, it calls a jquery function which calls resetForm(), amongst other things). Upon changing the value in the IntegerTextBox, the cancel button becomes enabled. Pressing the cancel button should reset the value of the IntegerTextBox.

    Observed behaviour: Pressing cancel does not change the value displayed in the IntegerTextBox (values in other fields of the form are reset immediately). However, the next time focus is set on the IntegerTextBox, the correct (reset) value is displayed.

    Is there a way to make the IntegerTextBoxFor update right away, when the cancel button is pressed?
    Thanks for any help!
    Luke

    Here's the code that I imagine would be relevant:
    In the View:
    @(Html.Telerik().IntegerTextBoxFor(m => m.Port)
        .EmptyMessage(Html.Stm(Language.MessageValueNotSet))
        .NumberGroupSeparator("")
        .HtmlAttributes(new { onkeyup = "EnableButtons()" }))
    ...
    <button type="reset" onclick="ResetForm()">@Html.Stm(Language.ButtonCancel)</button>


    The jquery function:
    // Resets the form
    function ResetForm() { 
        $('form').validate().resetForm(); 
        $(":input").hideErrorLabel(); 
        DisableButtons();
    }

    Reply

  • Answer Dimo Dimo admin's avatar

    Posted on Jun 9, 2011 (permalink)

    Hi Luke,

    I am glad to inform you that we have fixed this bug and changes will take effect in the next internal and official builds.

    I have updated your Telerik points for bringing the issue to our attention. Thank you.

    Best wishes,
    Dimo
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

    Reply

  • Landon avatar

    Posted on Oct 7, 2011 (permalink)

    Hi Dimo,

    My apologies for re-surfacing this thread, but I am also getting this same error and unfortunately my code isn't stable enough at the moment to risk an upgrade. Is there any possible work-around for this bug?

    Best Regards,
    Landon

    EDIT:

    For anyone else experiencing this problem and is not in a position to upgrade your MVC, I've found a workaround for the solution using the Telerik API:

    var textBox = $('#NumericTextBox01').data('tTextBox');
    textBox.value(0);

    This works the same as if you were to set a regular input box's text() or val().

    Reply

  • Dimo Dimo admin's avatar

    Posted on Oct 10, 2011 (permalink)

    Hello Landon,

    A workaround for people using older versions of our MVC components is to subscribe to the form reset event and set the NumericTextBox value via the API by using the value in the <input> element.

    // inside form reset handler
    window.setTimeout(function () {
          var ntb = $("#NumericTextBoxID").data("tTextBox);
          ntb._value(ntb.$element.val());
    }, 1);

    This is what the newer versions of the NumericTextBox do internally.

    Regards,
    Dimo
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / Telerik MVC Extensions (superseded) > NumericTextBox > IntegerTextBoxFor: value displayed upon resetForm() vs. focus
Related resources for "IntegerTextBoxFor: value displayed upon resetForm() vs. focus"

ASP.NET MVC NumericTextBox Features  |  Documentation  |  Demos  |  Telerik TV ]