I have copied the provided code to a standalone Html page to test it and I have noticed a JavaScipt error on the console:
I am also not sure if I understand the desired behavior based on the provided code. If you share what is the expected behavior we could try to assist in achieving it?
Additionally, I have noticed that in the SetColor() function the string "ClassName" is set as a value of the localStorage item instead of the variable ClassName. This would result in localStorage pair bgcolor: "ClassName" instead of bgcolor: "#ffffff" for instance.
Since this issue is generic and not directly related to Telerik I would suggest you research some resources about the usage of localStorage. Here are a couple of articles to start with:
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.