Basic property setting of TextBox Value not binding

I have created a empty Blazor page and put on the page a TextBox (textbox0). I setup the Page property mytext to contain the value "init" then I simply try to bind the property mytext to the TextBox Value setting by setting that to ${mytext}.

I receive the error: CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type.

Note: This works fine in Angular by the way.

Any ideas?

I tried to replicate such problem however everything worked correctly on my end:

Is your setup different?

My mistake, I did not change the property type from "dynamic" to "String". Re-tested and all works perfectly. Once again thanks for your quick response.

In continuation of this topic:
I need to pass a boolean value to the dialog to set the read-only property for the textbox.
Dialog call:
protected async System.Threading.Tasks.Task Button0Click(MouseEventArgs args)
DialogService.Open($"Editable textbox dialog", new Dictionary<string, object>() { {"IsEnabled", true} });

protected async System.Threading.Tasks.Task Button1Click(MouseEventArgs args)
DialogService.Open($"Readonly textbox dialog", new Dictionary<string, object>() { {"IsEnabled", false} });

Dialog page's load event:

Binding textbox property:

This works at runtime but has Radzen IDE error "The name 'parameter' does not exist in the current context.

Hi @Ivan,

When you specify somewhere in your app that you are going to open a page with parameters Radzen will generate properties in that page to receive the parameters. You can use the property directly without parameters.MyProperty and it should work in both runtime and design time. We will look on how to fix parameters. for the designer.

Yes, binding to a parameter works without an additional property. But the error in the designer will to be present.

Should also be addressed by the latest Radzen release.

Better now, thanks!
But there is still a comment:
if you use an enumeration as a parameter, an error appears in the editor. Everything is ok in runtime.
Add enum in main namespace:
namespace Test.Pages
public enum MyEnum
Open dialog with:
DialogService.Open("Dialog", new Dictionary<string, object>() { {"DialogType", MyEnum.Readonly} });
Binding readonly property component to parameter:

In editor:

In runtime:

Indeed Radzen doesn't support custom enums in design time at the moment. We will look into it.

1 Like

2.45.13 (Blazor) Support custom enums in design time.
It looks like it is still not fixed

Label's text binding with ${parameters.Mode} works normally
but binding to readonly property with ${parameters.Mode==MyEnum.Value} is not

Supporting that expression in design time would require knowing the parameter type beforehand (e.g. MyEnum). This however would introduce a big performance penalty as we would have to traverse the whole application.

Using ${Mode==MyEnum.Value} should work both in runtime and design time.

1 Like

Great! You save my day..
Please explain why a runtime error occurs when binding an ${Mode==MyEnum.Value} expression to the property "disabled" (components like dropdown, datepicker etc)
If these components has binding value then runtime error occurs.
The visibility property binding without problems.

What is the runtime error that you get when using ${Mode==MyEnum.Value}? We can't reproduce any runtime error when binding that expression to the Disabled property of a TextBox.

Please remind me where the Radzen's log file location (MacOS)

Binding to the disabled property of the text box does not cause errors.
An error occurs when binding to this property in dropdown, which has a value property attached

Message from output during complie:
dotnet: obj/Debug/netcoreapp3.1/Razor/Pages/Dialog.razor.g.cs(142,235): error CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type. [/Users/domivan/Documents/Radzen/Test/server/Test.csproj]

You can find it in the Troubleshooting help article. It however logs only design time errors. Runtime errors are shown in the Output window.

Here is a sample application which builds and runs fine - it uses an enum and sets the Disabled property of a dropdown to an expression. Does it work at your side? (24.5 KB)

Yes, your example works.
But I wrote that the error occurs when the dropdown is tied to the collection and has the value property set
In your example, just an empty dropdown, in which case there will be no error

Can you update my project so it fails as in your case? I am missing something which isn't obvious from your screenshots.

Ok, here is the updated project.
It has a compilation error.
If you remove the binding to the value property in the dropdown component, there will be no error.

For some reason the TValue of the DropDown isn't properly set. We will investigate. A workaround is to set it manually:

1 Like