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

Error while adding Min and Max values in TelerikNumericTextBox

4 Answers 687 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
Anju
Top achievements
Rank 2
Veteran
Anju asked on 02 Dec 2020, 09:15 AM

<TelerikNumericTextBox Min="0" Max="100" @bind-Value=@Model.HeadSkip  Id="header_skip"></TelerikNumericTextBox> 

After adding the Minimum and Maximum value it shows an error as below

 

The type arguments for method 'TypeInference.CreateTelerikNumericTextBox_0<T>(RenderTreeBuilder, int, int, T, int, T, int, string, int, T, int, EventCallback<T>, int, Expression<Func<T>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

The binding value is of type short and I am trying to restrict the negative numbers in numeric textbox.

 

4 Answers, 1 is accepted

Sort by
0
Svetoslav Dimitrov
Telerik team
answered on 03 Dec 2020, 11:51 AM

Hello Anju,

What I suspect is happening is that the Model.HeadSkip is a string value, whereas you should bind the value of the component to a numeric type. Below, you could see two code snippets, the first where the error is reproducible and the @bind-Value is bound to a string, and the second one (where it is not) - the @bind-Value is bound to an integer.

You can find more information on the suitable data types for the component from this documentation article.

Reproducible example:

<TelerikNumericTextBox Min="0" Max="100" @bind-Value="@NumericValue" Id="header_skip"></TelerikNumericTextBox>

@code {
    public string NumericValue { get; set; }
}

Working example:

<TelerikNumericTextBox Min="0" Max="100" @bind-Value="@NumericValue" Id="header_skip"></TelerikNumericTextBox>

@code {
    public int NumericValue { get; set; }
}

Does this help you move forward with your application? If it does not you can follow up on this thread.

Regards,
Svetoslav Dimitrov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Anju
Top achievements
Rank 2
Veteran
answered on 03 Dec 2020, 12:50 PM
Headskip is of Type Short 
 
1
Accepted
Svetoslav Dimitrov
Telerik team
answered on 03 Dec 2020, 01:24 PM

Hello Anju,

Since our 2.6.0 release, we support the short type for the NumericTextBox. What is happening that the types are different - for the Min and Max you provide integers (0 and 100). You could use the example below as a base to implement it in your own project.

<TelerikNumericTextBox Min="@((short)0)" Max="@((short)100)" @bind-Value="@NumericValue" Id="header_skip"></TelerikNumericTextBox>

@code {
    public short NumericValue { get; set; }
}

Regards,
Svetoslav Dimitrov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Anju
Top achievements
Rank 2
Veteran
answered on 03 Dec 2020, 01:42 PM
Thank you! Its Worked :)
 
Tags
NumericTextBox
Asked by
Anju
Top achievements
Rank 2
Veteran
Answers by
Svetoslav Dimitrov
Telerik team
Anju
Top achievements
Rank 2
Veteran
Share this question
or