Last post Jan 26, 2007 05:19 PM by jackfox
Jan 25, 2007 04:55 PM|jackfox|LINK
I converted our non-trivial 2003 C# website, consisting of 2 web projects, to a VS 2005 web site and finally got it to compile and run. Many of our user controls are in one project and used in pages on the web site (used to be a project under 2003, but I
did not convert as a "web project").
The problem I now have is the controls on the UserControls are all null the first time any code executes against them, which of course results in a null object exception. What in the world went wrong? They are all defined in the *.ascx.designer.cs class.
I even moved them back to the code behind class. That also didn't work. I tried explicitly assigning each one to = new WhatEver(), which of course works, but it seems there must be some other problem, and I shouldn't have to do this.
web site projectm
visual studio 2005
visual studio .net 2003
Jan 26, 2007 02:55 AM|JohanNL|LINK
Can you change the .ascx file to .aspx file and then run debugger.
Then you know if page is correct in VS.NET 2005
Jan 26, 2007 05:19 PM|jackfox|LINK
I could already set break points in both the control (in the client web project) and the page (in the main web project), but your idea led me to create a page in client project using the usercontrol, and that unveiled another bunch of problems. Eventually
I resolved it down to this problem
The base class includes the field 'MyControl_1', but its type (MyControl) is not compatible with the type of control (ASP.MyControl_ascx).
documented at http://support.microsoft.com/kb/919284.
Unfortunately I can't get any of the remedies recommended there to fix the problem.