Question

I have a project I'm working on in a Visual Studio 2003 and SQL Server 2005 environment. Lately I've been having some trouble with the codebehind files for my ASPX web pages. Some pages are referring to codebehind from other pages.

Recently, for example, I copied a page from one of my projects to use it as a starting point (it is for a form with multiple pages), After renaming it, the codebehind and other files followed suit. However after modifying the page to what I needed, I found out that it was still referencing the old codebehind (making references to controls that are no longer there).

I checked the aspx code, and the reference is correctly pointing to the new codebehind. I've tried building and re-building the project several times, resetting the IIS, deleting temp files and modifying the web config. No dice.

Was it helpful?

Solution

If you copy a page in Visual Studio and rename it, it will automatically change the Codebehind attribute in the <%@ Page declaration on the .aspx markup.

But what it won't do is change the name of the class in the codebehind file, or the class that the Inherits attribute on the declaration points to.

Firstly, change the Inherits to your new class name - this should automatically change the designer file to use the same class name.

Then change the class definition in the code-behind file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top