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

TValue for ValueExpression

1 Answer 429 Views
TextBox
This is a migrated thread and some comments may be shown as answers.
Rihen
Top achievements
Rank 1
Rihen asked on 11 May 2020, 07:20 AM

Hello,

I'm currently using a TextBox in one of my forms.

The problem is that the "Value" of the text box is made from a combinaison of different variables, with "ToString()", I cannot bind it to a specific string value.

The [Required] attribute is on a class, which does not contain a string value.

The purpose would be to be able to link "ValueExpression" to any variable like you can do with the validation message "  <ValidationMessage For="@AnyTypeRequiredValue"/>". Like this we will be able to have the field colored in red when the class is not filled and when it's not necesseraly a string.

Hope you understood my problem.

Have a nice day

 

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 11 May 2020, 12:57 PM

Hello,

The Blazor validation uses DataAnnotation attributes on the corresponding model fields - if the certain field does not have an attribute, it won't show error messages or block form submission.

If you can't have an appropriate field, you should create a view model that does. For example, its getter can perform the necessary calculations, or you could perform them elsewhere in the view-model and set its value as desired.

The TelerikTextbox requires a string field to bind to, like the standard <InputText /> - once you have the desired setup working with the InputText, it should work with the Telerik textbox.

 

Regards,
Marin Bratanov
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
TextBox
Asked by
Rihen
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or