Solved

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

Posted on 2009-07-13
4
233 Views
Last Modified: 2013-11-26
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
Comment
Question by:Loomy
  • 2
  • 2
4 Comments
 
LVL 28

Expert Comment

by:strickdd
ID: 24839826
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
 

Author Comment

by:Loomy
ID: 24840017
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
 
LVL 28

Assisted Solution

by:strickdd
strickdd earned 250 total points
ID: 24841457
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
 

Accepted Solution

by:
Loomy earned 0 total points
ID: 24867825
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Object Oriented Programming, C#, referencing, scoping. 13 69
Help with error in Query 2 31
"Emulate" TAB key when press Enter Key 3 44
reading excel file in .net 2 12
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question