Change ButtonStyle Based on Variable

I am trying to change the ButtonStyle to primary or success based on the value of a variable. If I data-bind the ButtonStyle property it does not compile:

error RZ9986: Component attributes do not support complex content (mixed C# and markup). Attribute: 'ButtonStyle', text: 'ButtonStyle.@myButtonVariable'

${myButtonVariable} is set to "success" or "primary" (string) depending on the style I want to set. I'm assuming it needs changed to something else.

Any help would be appreciated.

Thanks!

Bill

Indeed the syntax you are trying will not work. Your myButtonVariable should be of type ButtonStyle and not a regular string. Alternatively you can try the Enum.Parse method. Set the the ButtonStyle property to Enum.Parse<ButtonStyles>(myButtonVariable, true)

I was able to create a new variable of type ButtonStyle.

RadZenButton_Style

However when I data bind it to the button I get the following error:

Component attributes do not support complex content (mixed C# and markup). Attribute: 'ButtonStyle', text: 'ButtonStyle.@liverButtonStyle'

RadzenButtonDataBind

It will be fixed in the next update (early next week)

1 Like

This is confirmed working in 2.52.2

Thanks!