Showing posts with label coding. Show all posts
Showing posts with label coding. Show all posts

Friday, 29 July 2011

asp.net CodeBehind vs CodeFile

Applicable to ASP.Net 2.0 onwards

if it is a "web application" project - use CodeBehind
if it is a "website" project - use CodeFile

in regular ascx file:

<%@ Control Language="C#" AutoEventWireup="true" Inherits="My.Great.Web.SomeCtrl" CodeBehind=SomeCtrl.ascx.cs" %>


in regular aspx file:

<%@ Page Language="C#" AutoEventWireup="true" Inherits="My.Great.Web.SomePage" Codebehind="SomePage.aspx.cs" %>


in global.asax:

<%@ Application Language="C#" Inherits="My.Great.Web.Global" CodeBehind="Global.asax.cs" %>
More info here: ASP.NET Web Page Code Model