I can see, indeed, that the code above the section flagged as suspicious above is wrong, because the closing "}" is not yellow.
At the top of the page I have some using directives:
@using System.Configuration
@model CCRReporter.Models.TLISReportModel
@{
ViewBag.Title = "Transaction Line Item Sales Report Criteria";
ViewBag.PageName = ViewBag.Title;
}
...followed by a script section:
@section ScriptContent
{
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript" defer> </script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript" defer> </script>
// etc.
<script type="text/javascript">
var bSubmitting = false;
var WantsFocus = null;
var bFocusing = false;
var report_parms = null;
function SetTabOrder() {
$.each([
"#BeginDate",
"#BeginTime",
"#EndDate",
"#EndTime",
"#InputSite-input",
"#cmdAddSite",
"#InputDept-input",
"#cmdAddDept",
"#IncludeDepts",
"#ExcludeDepts",
"#UPCBeginsWith"],
function (i, n) {
$(n).prop("taborder", "y");
});
}
// ready handler
$(function() {
// etc.
...this jQuery has been validated via jsfiddle/jshint.
Here is the YSOD:
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Section blocks ("@section Header { ... }") cannot be nested. Only one level of section blocks are allowed.
Source Error:
Line 402:}
Line 403:
Line 404:@section MainHead
Line 405:{
Line 406: <link href="@Url.Content("http://code.jquery.com/ui/1.9.2/themes/smoothness/jquery-ui.css")" rel="stylesheet" type="text/css" />
Source File: /CCRReporter/Views/CCRCriteria/TLISReport.cshtml Line: 404
I've looked over all this code multiple times, and have no idea what the problem is. Has anybody run into this before, or know of a trick for finding just where the problem lies?
I still couldn't find any syntactical problem with the code, but on closer inspection, the logic of the code seemed quite bizabre (combination of bizarre and macabre):
It had a submit_button click handler that called $("form").submit();
If "submit_button" really is a submit button (input type="submit") - and it is!, why would that be necessary? Not only that, but the function called from the click handler had been declared this way:
$("#form0").submit(function() {
form0? What the Hec Ramsey?!? There is no "Form0" anywhere on the page...
Once I moved the code for submitting from the Form0 handler (which, I admit, I had previously changed from selecting the phantom 'form0' to 'form') to the submit_button handler, the much-awaited and yearningly longed for yellow background returned to the section's ending "}".
Voila!
Maybe the debugger is smarter than I thought: it goes on strike not only when the code doesn't compile, but also at times, apparently, when it (the code, or, by extension, the carbon-based biped who wrote it) a candidate for the loony bin.
Alas -- I know why the caged bird sings: he was trapped maintaining the code of birdbrains who had flown the coop!