Adding Change event handler to Checkbox fails to compile

I have a checkbox and want to add a Handler to the Change Event. If I Do this in the designer it fails to compile.
any idea what I am doing wrong? I've added simple invoke datasource method to show the issue.

Hi @timt,

This looks like a case where Blazor's type inference fails. Try setting the TValue parameter of the Checkbox explicitly like this:

We will try to implement some workaround in Radzen to handle this glitch.

I see its been added to the latest release and it's now working for me

Great stuff!

Ok quick update.

I have a similar issue with the Change event for Numeric input in that it wont compile with similar error. In addition I am binding to a int? field in my object. Will this causes a possible issue as the Numeric field tries to use decimal? I have tried to manually set the TValue attribute to decimal? and int? but no luck.

Is there anything else I can try please?


Unfortunately we couldn't find a workaround but to use a decimal property. Meanwhile we are working on a fix.

The latest update seems to have broken the checkbox change event code as per original post. The TValue is not being generated, I have to add it back in manually. Before the update it did seem to be added when the change event was present.


Is the CheckBox bound in your case and what is the property type or you have just Change event?

Ok, If I remove the existing event (created pre update) and add it back again the TValue is added for me (I then have to remove the manual one I added to avoid duplicate). So moving forward I am now OK :slight_smile:

Seems like it wont add the TValue to existing events?


Yep, when Change event is added Radzen will add additional info in the meta.

I have just updated to v2.41.3

the problem I had with the TValue for checkboxes is back.

After the update the TValue was not being generated in the razor for the checkbox. This happened last time I updated and had to delete and re-add the checkboxes. When re-added manually the TValue item would appear in the razor markup.

I can't keep re-adding controls each time I update.

Surely it's during the code generation this tag should be added or at least be remembered across updates?

Hope this makes sense and you can fix this.


Hi @timt,

We can't reproduce such an error with the latest release.

Here is how the original fix works:

  1. When the user adds an event Radzen tries to infer the property type.
  2. This property type is saved in the page metadata like this:
      "events": {
      "change": [
         "code": "Console.WriteLine(${event});",
         "type": "execute"
    "name": "checkbox0",
    "type": "checkbox",
    "value": "${value}",
    "valueType": "bool" // <-- valueType is used to output TValue

The fact that adding the change event handler adds TValue back means that the fix works as expected. If however TValue stops being generated then something has updated the page and remove the "valueType" JSON setting. Do you remember modifying the page or checkbox somehow?

No nothing changed, it was all working pre the update. You're right the valueType has gone when I look in the json file for that page but the change event code is still there.

In fact all of the checkboxes and numeric fields where I had a change event have stopped working. If I make a small change to the event code (add a space) in Radzen designer it regenerates and adds back the missing TValues so this is slightly better that replacing the component now I know what causes this.

Hope that helps narrow done the issue for you


Unfortunately we can't reproduce that still. Can you check in source control when did those valueType properties get removed?


I manually changed (touched) the event handlers and the TValues came back and I could run OK

I have just updated to latest version and I am back to where I started again once I closed and reopened my project they all disappeared again.

I have done this several times and watched the json file in VS as the project was reopened and rebuilt in Radzen and can see the TValue disappear from the json (and hence fails to compile and run the project)

I am now stuck as each time I reload I have to manually redit to add back the TValues.


We are doing our best to reproduce this issue. Are you doing anything else but opening the project?

Nevermind I think we got it.


Thanks for the update you sent through. I installed and glad to say it's now working.

Thanks for the professional and speedy response.


Is this issue fixed ?
Adding default value to a checkbox , ${false} the designer shows text instead of the checkbox component, " The type or namespace 'XXXMyPageComponent' could not be found (are you missing a using directive or an assembly reference? ).

Meta json of the page shows : valueType for checkbox "myModel.Pages.MyPageComponent"

Is this the same issue ?
easy to reproduce ::

  1. add check box to page
  2. compile
  3. add ${false} to value property of the checkbox


You can't use literals (e.g. true or false) for two-way bound properties in Blazor (setting Value makes Radzen generate @bind-Value="false" which is not valid Blazor statement).

As a solution either:

  • Use a page property set to false
  • Set Value as a custom attribute. Then it will render as Value="false" (and you would have to use the Change event to get the checked state).

the designer does not recover from this by its own, have to remove the valueType property that was added from the .json file .
Could this be addressed in a fix ?