Kendo Window标题中TM符号渲染异常,显示为™求助
I see the problem here—your ™ entity is getting double-encoded, which is why it's showing up as ™ instead of the ™ symbol. This happens because the Kendo Window's Title() method in ASP.NET MVC automatically HTML-encodes the string you pass to it. Here are a few straightforward fixes:
Solution 1: Use the Unicode ™ Character Directly
Most modern systems support Unicode characters natively, so you can just paste the ™ symbol directly into your title string:
@(Html.Kendo().Window() .Name("SmartHomeTerminationModal") .Actions(a => a.Minimize().Close()) .Animation(false) // ... your existing content configuration ... .Draggable() .Title("SmartHOME™") // Use the actual ™ symbol here .Visible(false) .Width(800) )
Solution 2: Use Html.Raw() to Bypass Encoding
If you prefer to use the HTML entity syntax, wrap the string in Html.Raw() to tell the helper not to encode it:
@(Html.Kendo().Window() .Name("SmartHomeTerminationModal") .Actions(a => a.Minimize().Close()) .Animation(false) // ... your existing content configuration ... .Draggable() .Title(Html.Raw("SmartHOME™")) // Html.Raw prevents double encoding .Visible(false) .Width(800) )
Solution 3: Set the Title via JavaScript (Fallback)
If the above methods don't fit your setup, you can override the title after the window initializes using JavaScript. This avoids server-side encoding entirely:
// Keep your existing Window code with a placeholder title @(Html.Kendo().Window() .Name("SmartHomeTerminationModal") .Actions(a => a.Minimize().Close()) .Animation(false) // ... your existing content configuration ... .Draggable() .Title("") // Empty placeholder .Visible(false) .Width(800) ) // Add this script at the bottom of your view <script> $(document).ready(function() { const terminationWindow = $("#SmartHomeTerminationModal").data("kendoWindow"); terminationWindow.title("SmartHOME™"); // JS renders the entity correctly }); </script>
Any of these approaches should fix the rendering issue and show the ™ symbol properly in your window title.
内容的提问来源于stack exchange,提问作者A.Stekl

