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 most control over what I needed to render on the client

  • April 12, 2019

Recently I tried to construct some javascript code from my C# code-behind. This way I had 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!  


Image Description

Entrepreneur, Senior Software Engineer .NET, Sitefinity Solution specialist, Orchard CMS enthusiast, Product Owner

All Author Posts

Got another minute? Check out:

Image Description

Call us

+31 (0) 36-2000196
Image Description

Address

Grote Beer 57, 3893 DJ Zeewolde
NLThe Netherlands

Please sign in

Signin to manage your account.

Do not have an account? Signup

OR