ASP.NET 2.0 introduced the CompilationMode attribute to let the developers decide how to compile individual pages, user controls and master pages. You can set the value to these three values:

  • Always
  • Auto
  • Never

This is the definition from MSDN:

"The CompilationMode enumeration values indicate whether a page or control should be compiled at run time. When no compilation mode is specified, the default value is Always. Setting a page to never compile using the Never attribute will increase performance by disqualifying the specified page in the compilation process."

The attribute can be set on the individual page and control declarations like this:

<%@ Page compilationMode=”Never” %>
<%@ Control CompilationMode="Never" %>

Or in the web.config’s system.web section.

<pages compilationMode="Auto" />

If you set the CompilationMode to Never on a page, that page will never get compiled. If there is any C#/VB code on that page an error will be thrown. I use it for user controls that don’t have any code, but still hosts various controls like other user/custom controls or the built-in Login control. If there are lesser pages to compile, you get a slight performance boost.

I recommend that you don’t use the web.config to set the CompilationMode, but on the individual pages and controls to avoid surprises. However, if you want to apply this to an already existing web application it’s much easier to set the CompilationMode to Auto in the web.config depending on the size of the web application.

I recently built a JavaScript function in HeadLight that filled a textbox from JavaScript and then disabled the textbox to prevent the user to alter its contents. When the form was submitted, it didn’t submit the contents of the disabled textbox. It puzzled me, but then I found that ASP.NET 2.0 doesn’t submit client-side disabled controls by default. However, there is an easy way to force it to do so.

All you have to do is to put this line in the Page_Load:

Page.Form.SubmitDisabledControls = true;

The reason why I’ve never seen this property before, is that I have never had the need for it. I guess I’m just slow, but then again, slow is the new fast.