I have some javascript and c# code inside one of my views that is deeply nested. Heres the general structure something like this:
@if(something)
{
<script type="text/javascript">
@if(something_else)
{
<text>
...some javascript...
event: function(){
@ViewBag.Property = value;
}
...some more javascript...
</text>
}
@else if(something_else_else)
{
...some more javascript...
}
<script>
}
It works fine in the html file but I would like to put it in an external js file and instead just load like this:
@if(something)
{
<script type="text/javascript" src="@Url.Content("~Scripts/thescript.js")"></script>
}
However if I try to do this I get error: missing } in XML expression
I tried wrapping the contents in but it still complains with same error. Anybody know if this is possible because its a rather long script and making my view very convoluted.