Solved

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

Posted on 2009-07-13
4
225 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now