Development

Use StringBuilder with bracelets... just so you know!

Recently I tried to construct some javascript code from my C# code-behind. This way I had the most control over what I needed to render on the client

Daniel Plomp

April 12th, 2019

Recently I tried to construct some javascript code from my C# code-behind. This way I had the most control over what I needed to render on the client. I tried this code:  

stringBuilder.Append(string.Format("{ swfPath:'{0}', supplied:'mp3', wmode:'window' }); });", flashPath));

Which resulted in an error. The solution was to double the bracelets in this string like this:

stringBuilder.Append(string.Format("{{ swfPath:'{0}', supplied:'mp3', wmode:'window' }}); }});", flashPath));

And then it worked as expected. Just so you know! 

All rights reserved © ZimplerApps 2019