Monday, September 5, 2011

How to change CodeBehind attribute to CodeFile attribute.

Either in user contol or in .aspx page codeBehind attribute appears like this.

<%@Control Language="C#" AutoEventWireup="true" CodeBehind="SampleForm.ascx.cs" Inherits="SampleForm" %>

It inherits from "SampleForm". It is the respective class name in code behind.
public partial class SampleForm {}

Change the CodeBehind attribute to CodeFile as below:
  
<%@Control Language="C#" AutoEventWireup="true" CodeFile="SampleForm.ascx.cs" Inherits="SampleFormChanged" %>

Change respective class name for inherits attribute. Then SampleForm.aspx.cs file class name should be
 
public partial class SampleFormChanged{}

Here there is no need to change any file names. Changing CodeBehind to CodeFile attribute is useful during partial deployment. There is no need to build anything.

No comments:

Post a Comment