ASP.NET 1.1 to ASP.NET 2.0 Migration #1

Guess this is the easiest migration tip that everyone already know. But I still like to share to those people who do not know.

ASP.NET 1.1

In your ASP.NET source file, you will be using Codebehind like this:

<%@ Control Language="c#" Codebehind="SomeFile.ascx.cs" ... %>

Just imagine you have 2 text boxes controls in your designer form.

In your code behind which is your c# code, you will see this:

public class SomeFile : System.Web.UI.UserControl

{

  protected System.Web.UI.WebControls.TextBox txtUserName;

  protected System.Web.UI.WebControls.TextBox txtPassword;

}

The question is how do you migrate this over to ASP.NET 2.0

ASP.NET 2.0

In the ASP.NET source files, changes Codebehind to CodeFile

<%@ Control Language="c#" CodeFile="SomeFile.ascx.cs" ... %>

Then in your code behind, add partial keyword before your class. Later comments the 2 TextBox declarations:

public partial class SomeFile : System.Web.UI.UserControl

{

  //protected System.Web.UI.WebControls.TextBox txtUserName;

  //protected System.Web.UI.WebControls.TextBox txtPassword;

}

That's simple right :D Hope you find it useful.

Published Tuesday, September 26, 2006 8:22 AM by chuawenching