This question is locked. New answers and comments are not allowed.
Is there a way to replace/escape/encode special characters when using ClientTemplates?
For example:
.ClientTemplate( @"<a href=""javascript: ShowOffer(<#= OfferID #>, '<#= OfferName #>');""><#= OfferName #></a>" )
The above will not work if OfferName contains a single quote (') for instance and something of the sort <#= OfferName.ToString().Replace(""'"", ""\'"") #> unfortunately doesn't work (only works for server template... obviously).
Only way I can think of is to include another field in my ViewModels, something like OfferNameEncoded but I will have to re-write a ton of stuff to do this. There has got to be a an easier way. I can't believe I hadn't thought of this and have all these broken codes all over the place. Can something like $.telerik.formatString be used to achieve this or have I been programming too much today and need to go to bed? Help!!! :/
Thanks!
For example:
.ClientTemplate( @"<a href=""javascript: ShowOffer(<#= OfferID #>, '<#= OfferName #>');""><#= OfferName #></a>" )
The above will not work if OfferName contains a single quote (') for instance and something of the sort <#= OfferName.ToString().Replace(""'"", ""\'"") #> unfortunately doesn't work (only works for server template... obviously).
Only way I can think of is to include another field in my ViewModels, something like OfferNameEncoded but I will have to re-write a ton of stuff to do this. There has got to be a an easier way. I can't believe I hadn't thought of this and have all these broken codes all over the place. Can something like $.telerik.formatString be used to achieve this or have I been programming too much today and need to go to bed? Help!!! :/
Thanks!