Rectangle 27 0

As an addition to the other answers on here, I'd like to add that if you're using Kendo UI with ASP.NET Razor view syntax, and your format string has to be passed in from the input tags themselves, you'll need to turn the Kendo UI format string into a string literal, or JavaScript will end up escaping your escape characters. For example, in an application I'm working on now, we have a custom data field for format that an html helper uses to create the Kendo NumericTextBox.

<input data-custformat="##.##\\%" value="12"/>

fails to render the format correctly. The output looks like 1200\%, as the double backslash is escaped to a single backslash, and the field maintains the default Kendo percentage behavior of multiplying the field's value by 100.

<input data-custformat=@(@"##.##\%") />

formats the number correctly, and overrides the default Kendo percentage behavior. Notice that in the string literal, only a single backslash is used.

This is a somewhat niche and subtle issue, but caused a bit of frustration while trying to integrate Kendo UI with ASP.NET MVC.

kendonumerictextbox - Adding a % sign to a percentage in Kendo Numeric...

kendo-ui kendonumerictextbox
Rectangle 27 0

Based on your error , you must be using ' ' (simple quotes ) somewhere and it get compiled by the razor engine. try to change all your ' in \" in your "" strings.

try for yourself , if you declare a string like this 'aa' you will get the same error in Csharp ,because you have to use "aa" to declare a string literal. '' are for character literals.

anyway in my opinion you should not mix js and C#. if you need to pass variables from C# to Js use either ajax ,or another solution like hidden input fields. or create templates like that :

<script type='text/template' id='mytemplate'>
<div>@myVar</div>
</script>

and get the content of the template with

$templateContent= $("#mytemplate").html()

tnkks dude ^^ but it does not work i steel have the problem with the @ tag

html - asp.net razor special character issue in javascript variable - ...

javascript html asp.net-mvc razor webmatrix