Web: Rectangle => Backgroundcolor on the fly without Styles?

I have a database with RGB-color values.

I want to show some rectangles, with the backgroundcolors of these RGBs. Because the colors are dynamically from the database, I can’t make styles.

Is there a possibility to change background colors of Rectangles “on the fly”?

Yes, using JavaScript.

dim clr as String = "rgb(255,0,255)" self.ExecuteJavaScript("document.getElementById('"+Rectangle1.ControlID+"').setAttribute('style', 'background-color: "+clr+" !important;') ;")

Thanks, Michel. Is it possible, using JavaScript, to change the background-color for each of the four states of a style (Normal, Hover, Pressed, Visited) ?

The simplest would be to create an empty webstyle applied to the rectangle , and to change it’s selectors in code https://www.w3schools.com/cssref/sel_hover.asp