Need empty value when using NumericTextBoxFor(...)

2 posts, 0 answers
  1. BigzampanoXXl
    BigzampanoXXl avatar
    62 posts
    Member since:
    Jan 2007

    Posted 10 Jan 2013 Link to this post


    first of all, this is how I implemented the NumericTextBox, bound to an integer:
    @(Html.Kendo().NumericTextBoxFor(m => m.Number)

    My problem is:
    As soon as I bind something against the NumericTextBox (when I use NumericTextBoxFor(...)), the value is never empty. It looks empty but as soon as the user clicks inside the TextBox the value of the bound integer (int.MinValue or whatever value the property has) is shown. First of all - the value (int.MinValue) makes no sense because the Min-property is set to 1. Secondly, why is there anything? The NumericTextBox should be empty, because I didn't set a value.

    This problem causes, that the user has to delete the value first before he is able to insert something. On initialisation of the NumericTextBox it should be empty - but it should also be bound to a property.

    Is there any workaround or solution for this problem? Hope someone can help me.
  2. Daniel
    Daniel avatar
    2177 posts

    Posted 14 Jan 2013 Link to this post


    This behavior is expected and is by design. The value is automatically populated from the model when the NumericTextBoxFor helper is used or the name is the same as the name of a property from the model. The same behavior can be observed for any HTML helper. If you wish to avoid this, I can suggest to use the NumericTextBox helper instead and set the input name through the HtmlAttributes method e.g.

        .HtmlAttributes(new { name = "Number" })
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top