To be blunt, this is a terrible way to deal with JavaScript. Instead, add an empty .JS file to your project and put the JavaScript in it. Then in the head of your page reference it using a script tag.
You can then call it when loading by using jQuery's document.ready
.ready() | jQuery API Documentation[
^] method.
Unless there is a very good reason, don't build big strings of script through C#.