Solved

Controls from toolbox not recognised in code behind

Posted on 2009-06-30
4
199 Views
Last Modified: 2013-11-27
I had a .net 1.1 asp.net application that I have opened up in VS2008. It was converted ok (no error messages)

If I add a control from the toobox the control is not recognised in the code behind.

I noticed in the code behind there are declarations for the existing controls. (see below)

If I add a declaration for my new control everything seem fine. I don't really want to have to do this and under 2.0+ are the controls defined somewhere else.

Can I get this to behave like a 2008 solution?

TIA


public class NewsItems : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Panel Panel1;
		protected System.Web.UI.WebControls.Repeater Repeater1;
                protected System.Web.UI.WebControls.GridView GridView1;
...

Open in new window

0
Comment
Question by:Philip Pinnell
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
nikege earned 500 total points
ID: 24749464
I think the problem is that .Net 1.1 did not know about 'partial' classes. VS2008 creates 3 files for each web page: .aspx file, aspx.desiner.cs and aspx.cs (for the case of C#, or .vb for the case of VB)
.aspx - contains layout
.aspx.cs - contains your codebehind
.aspx.desiner.cs - contains code generated by VS. VS automatically updates this file on each changing.
.aspx.cs and aspx.desiner.cs are the partial classes.

it should look like this :
public partial class Default: Page

If VS did not create 'desiner' files for you project I think you will have to add all controls manually to your code behind.
Try to add new web page to your project, just to see how VS creates new page.
0
 
LVL 13

Author Comment

by:Philip Pinnell
ID: 24755138
the .aspx.designer.cs files are there but they are not connected to the .aspx and .aspx.cs.

What I have done is add a new page for each one and copied the code over. Just as well there are not too many.

It seems to me that the conversion from 1.1 hasn't been done properly
0
 
LVL 2

Assisted Solution

by:nikege
nikege earned 500 total points
ID: 24756165
>>What I have done is add a new page for each one and copied the code over. Just as well there are not too many.
So did you solve your problem?

>>the .aspx.designer.cs files are there but they are not connected to the .aspx and .aspx.cs.
Check if aspx.desiner.cs contains the same class as aspx.cs with 'partial' keyword. Also these parts should be defined in the same namespaces and aspx file should refer to the correct class (CodeFile and Inherits atributes of @Page directive) also all parts of aspx page should be included into the project.
0
 
LVL 13

Author Comment

by:Philip Pinnell
ID: 24762033
Well it seems like a work around. To me the conversion from 1.1 didn't work properly

The newly created forms with the old code pasted in didn't seem to be any different from the originals but they seem to be working ok
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

773 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