At my previous job, our team architect was strongly against including any server side code in the markup, even simple ID’s, so this code would not be allowed to get checked in:
<script>
var el = document.getElementByID('<% SomeElement.ClientID %>')
</script>
instead you had to inject it into javascript via Page.ClientScript.Register…
His reason was that asp.net has to recompile a page every time if it has those server code includes.
That didn’t sound right for me but I couldn’t find any proof of either.
Any ideas? Does that change performance or not? I know that server side code in markup is not good because of difficulties in debugging and readability and the whole idea of separatin gcode form markup, but I am only interested in performance differences.
Thanks!
Your architect is wrong.
ASP.NET compiles a page once, regardless of whether or not it contains any C# code. It will recompile the page only if it detects that the ASPX file was changed since last compilation.