Skip to content

Commit ab62f35

Browse files
kb(slider):add kb for max parameter zero in slider (#564)
* kb(slider):add kb for max parameter zero in slider * Update knowledge-base/slider-max-parameter-zero-error.md Co-authored-by: Dimo Dimov <[email protected]> * Update knowledge-base/slider-max-parameter-zero-error.md Co-authored-by: Dimo Dimov <[email protected]> * Update knowledge-base/slider-max-parameter-zero-error.md Co-authored-by: Dimo Dimov <[email protected]> * Update knowledge-base/slider-max-parameter-zero-error.md Co-authored-by: Dimo Dimov <[email protected]> Co-authored-by: Dimo Dimov <[email protected]>
1 parent 928d14c commit ab62f35

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
title: Requires the Max parameter error in Slider
3+
description: Blazor Slider requires a Max parameter and throws an error if zero is set.
4+
type: troubleshooting
5+
page_title: Requires the Max parameter error in Slider
6+
slug: slider-kb-max-parameter-zero-error
7+
position:
8+
tags:
9+
ticketid: 1541425
10+
res_type: kb
11+
---
12+
13+
## Environment
14+
<table>
15+
<tbody>
16+
<tr>
17+
<td>Product</td>
18+
<td>Slider for Blazor</td>
19+
</tr>
20+
</tbody>
21+
</table>
22+
23+
24+
## Description
25+
I'm using the Telerik Slider, and I can't set Max to 0. When I set the Max parameter to zero, the component throws an error.
26+
27+
## Error Message
28+
>warning ArgumentException: Telerik.Blazor.Components.TelerikSlider`1[System.Int32] requires the Max parameter.
29+
30+
## Cause\Possible Cause(s)
31+
The `Max` parameter is a required attribute and the component is checking if it is set. If the developer doesn't set any value for `Max` and the Slider `Value` type is `int`, then the `Max` parameter value will match the default value of the `int` type. This causes the observed error. The default value for the non-nullable `int` type is 0, and when you explicitly set `Max` to 0, the component acts like there is no parameter value set and still throws the error.
32+
33+
## Solution
34+
You can avoid the exception by using a nullable type for the Slider `Value`.
35+
36+
>caption Set Max parameter to zero in the Slider
37+
38+
````CSHTML
39+
@* Example with nullable type of the value *@
40+
@Volume
41+
<br />
42+
<TelerikSlider @bind-Value="@Volume"
43+
Min="-3"
44+
Max="0"
45+
SmallStep="1"
46+
LargeStep="1"
47+
Width="400px">
48+
</TelerikSlider>
49+
50+
@code{
51+
int? Volume { get; set; }
52+
}
53+
````

0 commit comments

Comments
 (0)