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

[Solved] NumericTextBox throws as error on AddModelError

1 Answer 7 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Marin
Top achievements
Rank 1
Marin asked on 25 Aug 2011, 03:38 PM

When is added model error for NumericTextBox, NullReference error message is thrown in InputComponentExtensions.cs

public static string GetAttemptedValue<T>(this IInputComponent<T> instance) where T: struct
{
    ModelState state;
    if (instance.ViewContext.ViewData.ModelState.TryGetValue(instance.Name, out state))
    {
            return state.Value.AttemptedValue;
     }
 
    return string.Empty;
}

state.Value is null. I add checking and now is working fine.

public static string GetAttemptedValue<T>(this IInputComponent<T> instance) where T: struct
{
    ModelState state;
    if (instance.ViewContext.ViewData.ModelState.TryGetValue(instance.Name, out state))
    {
        if (state.Value != null)
        {
            return state.Value.AttemptedValue;
        }
    }
 
    return string.Empty;
}

 

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 25 Aug 2011, 03:48 PM
Hello Marin,

 
This is a known issue, which I am glad to inform you is already fixed in the latest internal build of Telerik Extensions for ASP.NET MVC.

Best wishes,
Georgi Krustev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
NumericTextBox
Asked by
Marin
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or