Why I can't use "</script>" in my C# code when constructing client script blocks? Why do I have to split "</script>" string into two chunks like
Like recommended, for example, here or here? (See also this bug). Why this snippet:
was fine in VS 2003 HTML editor, but produces an error in VS 2005?
The issue is well known since .NET 1.0. ASP.NET runtime is not able to identify that "</script>" is a string since runtime code does not parse script block content. Why? Because ASP.NET runtime supports pretty much every .NET-compliant language and it cannot assume particular syntax of the code in script blocks. Some languages may use single quotes, some may employ double quotes, some may do something else. The string may appear in comments and comment syntax is quite different is different languages. It is not possible to have a parser for every programming language in existence. Runtime has relatively simple parser that separates server-side elements from client-side elements and it identifies end of script blocks by doing plain text search for </script>. Simple parser also improves application performance. Actual script block content is eventually gets passed to the correspondent language compiler which knows how to deal with it.