Compile error when 2 pages use same codebehind file

  • Thread starter Thread starter Thomas Connolly
  • Start date Start date
T

Thomas Connolly

I have 2 pages referencing the same codebehind file in my
project. Originally the pages referenced separate code
behind files. Once I changed the reference to the same
file, everything worked fine while the file was in the
project directory. When the obsolete file was removed
from the project directory, my application will no longer
compile. Can someone please help with this issue?

Thank in advance,
Tom
 
Yes I did get an error message saying that the source
files of the obsolete pages cannot be found.
 
To be more specific, here is the error:
Source file 'C:\Inetpub\wwwroot\WYIRIS\FAQ_Txt.aspx.cs'
could not be opened ('The system cannot find the file
specified. ')
 
Open the .csproj and .sln files with a text editor, and search for
references to the obsolete file. I have had similar problems when deleting
unwanted code behind files.

Regards

Ron
 
Tom,

Did you remove the reference from the Page directive? I'm asking because I
want to try and reproduce your problem and I haven't been able to do so. I
have two Webforms. I changed the second's Page directive to indicate that
the codebehind file is the first's codebehind file and I also changed the
class that it inherits. (Did you do that?) When I compile after deleting
the original codebehind, it works fine.

The only thing I can think of is that you did not change the class that
your Webform inherits from.

Jim Cheshire
Developer Support
ASP.NET
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.


--------------------
 
Yes I did change both the class and the code behind file
in the page directive. Keep in mind that in the IDE,
everything runs fine. Try this, keep aspx page 2
referencing the code behind file in aspx page 1. Delete
the obsolete code behind file from the original aspx page
2. save everything. Compile. Close the IDE and manually
navigate to the page using your browser. Does it load.
 
Tom,

I am replying here so that others can see the response.

What you need to do is open each one of these pages in VS.NET after you
move the old code behind. When you do, VS.NET will update project view
with the new code behind and will put a warning icon over the old code
behind. Right-click the old code behind with the warning icon and choose
delete. After you do this for each of your files, it will work fine.

Hope that helps.

Jim Cheshire
Developer Support
ASP.NET
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
X-Tomcat-ID: 459707228
References: <[email protected]>
<[email protected]>
<[email protected]>
 
Back
Top