Solved

Controls from toolbox not recognised in code behind

Posted on 2009-06-30
4
198 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
Comment Utility
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
Comment Utility
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
Comment Utility
>>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
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

728 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

11 Experts available now in Live!

Get 1:1 Help Now