Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 240
  • Last Modified:

ASP.C# controls not being referenced in code-behind

I've been emailed all of the solution files for a website that a colleague has created in VWD Express, which I've copied onto my development machine, which uses VS Team System 2008.

The problem is that VS seems to have 'lost' all of the control declarations in its code-behind pages leaving me with 1174 errors to sort out.

Is this due to something that I may have inadvertently done or is VS just being difficult for the sake of it?

More importantly is there a simple and quick way to rectify this rather than manually add all of the control declarations again?
0
Loomy
Asked:
Loomy
  • 2
  • 2
2 Solutions
 
strickddCommented:
My guess is the original project was developed in .Net 1.1. This declares all the controls in the full code-behind file while .Net 2.0 and above use partial code-behinds. I believe all you need to do is update your <@ Page> directive to be .net 2.0 compliant (namely use the CodeFile="" attribute)
0
 
LoomyAuthor Commented:
You're right in that the original project was developed in .Net 1.1 however I was told that this project was working in VWD and my aspx pages already have the CodeFile attribute (see below) but it still doesn't seem to pick up the controls.
<%@ Page language="c#" Inherits="Portal.Admin.EditNewsArticle" validateRequest="False" CodeFile="EditNewsArticle.aspx.cs" %>

Open in new window

0
 
strickddCommented:
It looks like you are missing the Inherits attribute. This is set to the namespace of the partial class (in your case probably "EditNewsArticle" unless it is in a subfolder).

Other than that the issue may lie in the web.config.
0
 
LoomyAuthor Commented:
Thanks for the pointers but nothing seemed to help as even with the relevant attributes in place it still didn't work.

In the end, for each page in the app, I added a new page and copied the html and cs from the old files into the new files, renamed the original file, then renamed the new file to the original filename.

Very time consuming and very tedious but at least it worked.
0

Featured Post

Microsoft Certification Exam 74-409

VeeamĀ® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now