There are three ways to write code in an ASP.NET web form: the mixed code method, inline code method, and code-behind method. The code-behind method, which is the default in Visual Studio .NET, separates the code into a separate file from the HTML content for better readability and maintainability. The code-behind file is compiled into the web page and associated using attributes in the @Page directive when the application starts up.