In MVC3, running the razor view engine, I've had braces really mess up the parsing of the view.
For instance, if you have:
@using(Html.BeginForm()){
<div>hello!</div>
<script type="text/javascript">
$(document).ready(function () { alert("ready!"); });
</script>
}
You may have issues with the script's braces. Try changing it to:
@{ Html.BeginForm(); }
<div>hello!</div>
<script type="text/javascript">
$(document).ready(function () {
alert("ready!");
});
</script>
@{ Html.EndForm(); }
This may or may not be the answer to your question, but it took me forever to figure out what was wrong with a few of my forms. I wasn't embedding scripts in them, though.. it was blocks for conditional logic that would break everything for me.
EDIT
After a little more research, I found an issue someone had which led me to the solution: aspnet.codeplex.com/workitem/7551.
My commit message (from a codebase I don't physically have access to any longer) suggests it may have been bad markup. The dev who wrote the offending pages liked to use capitalized tags, even though we were using XHTML 1.1 doctype. He also had a lot of attributes being conditionally compiled and/or populated. For example:
<div class="something @myHelper(someFlag)"></div>
<div @{ isSomeFlag ? <text>class="asdf"</text> : "" }></div>
My solution should be considered a temporary fix.