Answered by:
Error: name 'lblSubTitle' is not declared

Question
-
User-153404742 posted
Hi,
I don't know but this is a really simple error. When I create a hyperlink or any object in the html, and try to use it in the code behind, it says name 'objectName' is not declared. When I try to use say a label in the codebehind lblTest, after I put a .(dot) after it, the property and methods list should pop up, but it doesnt since object is not recognized. I don't have a problem with all the other objects that were previously created, just the ones that I add now aren't being recognized. In the previous versions of visual studio, the controls were added at the top after the line:
Inherits System.Web.UI.Page
For example, if I had a label control in the html part named lblTest, it would place the following line in the code behind:
Protected WithEvents lblTest As System.Web.UI.WebControls.LabelHowever, this is not seen in the 2005 version. Is that the reason the conrol is not being recognized?...Do I have to explicitly place these lines of code for every control I add to the page? It doesnt seem like it since all the other controls that I previously created on this page don't have these lines of code and I can access them. Thanks for your help,
Tuesday, March 28, 2006 1:37 PM
Answers
-
User-160449870 posted
This solution works for "the control is not found" false error report in Visual Studio
I built a web site with around thirty pages. Several months ago I added some controls to an existing page and after compiling the website I started recieving an error listing for each control that I had added to the page. It stated "Name "ControlWhateverTxt" is not declared". I knew that this was a compiler error because 1) The webpage would run and utilize the controls in spite of the reported error 2) When I deleted the controls I would recieve a different error... and 3) I noticed that I recieved the error from any and all controls that I drug onto the page from the toolbox from a certain point of time forward. The controls declared previous to this time remained had no problems of thsi nature. My first tack was to delete the controls and drag new ones over from the tool box - same error. Next I stripped the code out of the .aspx and aspx.vb files and pasted them into new files with new names. When I recompiled the program it continued to report errors in the original files BUT NOT the cloned files, which confirmed to me that some kind of compiling data visual studio was keeping behind the scenes had become corrupt for the broken page. Satisfied that I had solved the problem I renamed the original files to archive them, and then renamed the cloned files to the names of the originals and viola - the bug came back! I messed around with some other things and finally gave up and lived with the false compiler errors for several more months until they became such a problem debugging other pages that I was forced to deal with them. I finally found a solution that worked from one of the many posts on the internet. I felt compelled to re-post it here because it is critical the at steps below are taken in the exact order they are listed. Here is the work around in black and white.
1) Create a NEW WebForm (naming it "OrginalPageName_2" is helpful)
2) Copy the HTML code from the original .aspx file to the new blank .aspx file - do the same with the aspx.vb code behind file.This is kind of 101 but make sure that you don't overwrite the first line in the new .aspx file when you paste the original code to it - in other words copy everything from the second line down in the transfer because the first line of code syncs the newly created page to it's code behind page.
but leave this! <%
@ Page Language="VB" AutoEventWireup="false" CodeFile="OriginalPageName_2.aspx.vb" Inherits="OriginalPageName_2" %>also along the same lines when you copy the code behind file from the orignal aspx.vb file to the new aspx.vb file - confirm that the "Partial Class" declaration matchs the "Inherits=" parameter of the new .aspx file. If you have pasted over it with the code from the original file you will have to rename it back to what it was.
3) HERE IS THE CRUX OF THIS WORK AROUND! DO NOT rename the original files first and try to save them and then rename the new ones! If you need to save the original files go to windows explorer and make a copy of them in a ANOTHER FOLDER OUTSIDE OF YOUR WEBSITE. Then go back to Visual Studio and DELETE the original .aspx file using the SOLUTION EXPORER. This will automatically take out the aspx.vb code behind file and MORE IMPORTANTLY this seems to remove the corrupt debbuging information associated with the file name from the compiler. Once the original files ARE GONE you can rename the new clones to the original names and the compiler will create a NEW SET of behind the scenes status files for the web page that no longer report false bugs for files of that name. If for some reason that page or some other one becomes permenantly corrupted again you now know what to do.
There is supposed to be some kind of patch for this floating around. I installed several service packs and they didn't fix it though...
Whew! - Bugs like this in the compiler are aggravating and expensive to developers. - this one cost me several thousand dollars in diverted development time... I would like to thank mdrols from this forum who took the time to share the solution above more or less the way I presented it. I re-posted his solution because I had actually tried a variation of it previously and it didn't work for me because the SEQENCE IS ABSOLUTELY CRITICAL.
I must have read at least fifty posts about this bug and he was the only one that cracked it. His effort motivated me to stop what I was doing and help the next guy down the line like he did. While I was writing this post It hit me that about half of the solutions I find to problems come from these posts. If you think about it, it's pretty amazing that anyone stops to post a solution to a problem on the net because it takes time, which in most cases is development money. I guess if you work for someone else then it is their nickel, but even then it's still takes some effort... It's Christmas and I wouldn't wish this bug on anyone! Thanks mdrols - you Da man!
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, November 24, 2007 11:46 AM
All replies
-
User-1363174918 posted
VS 2005 uses partial class model one of the benefits of which is that you don't have to declare controls twice. It is sufficient to declare control in markup and declaration will be generated automatically. You don't see generated code, code file only contains 'user code'. It is difficult to say what is wrong, but please verify that
1. Control has runat="server".
2. Control ID is correctly spelled.
3. Control is in the <form runat="server">.
Tuesday, March 28, 2006 7:52 PM -
User-153404742 posted
Hi,
I've checked all the points that you mentioned and I have those set up correctly. Any other ideas as to what might be causing this? Thanks
Wednesday, March 29, 2006 11:21 AM -
User-1363174918 posted
Can you post markup of the page and the code in the class? The issue might be in the page directive: does it refer to the correct code file?Wednesday, March 29, 2006 1:08 PM -
User-153404742 posted
Hi,
HTML code is as follows:
<%
@ Page Language="VB" AutoEventWireup="false" CodeFile="LessonPlan.aspx.vb" Inherits="LessonPlan" %><
html><
head><
title>LessonPlan</title> <meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR"> <meta content="Visual Basic 7.0" name="CODE_LANGUAGE"> <meta content="JavaScript" name="vs_defaultClientScript"> <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"></
head><
body><
h1 align="center"><b>Lesson Plans</b></h1> <h4 align="center">Click on the Link under the Title to view its Lesson Plans</h4> <H5></H5> <hr align="center" width="100%" color="#cc9900"> <form id="Form1" method="post" runat="server"> <asp:repeater id="repeaterLessonPlans" runat="server" OnItemDatabound="lesson_plan_onItemDataBound" OnItemCommand="lesson_plan_onItemCommand"> <ItemTemplate> <h5>Title</h5> <asp:LinkButton CommandName = "incrementCounter" id="lblTitle" ForeColor = "#0000ff" Text = '<%# DataBinder.Eval(Container.DataItem, "title")%>' runat="server" /> <br /><br /> <asp:hyperlink ID="hpSubTitles" runat="server" ForeColor="#0000ff" Text="Click here to see more documents and resources for this lesson"></asp:hyperlink> <h5>Description</h5> <asp:Label id="lblDescription" ForeColor = #cc6600 Text = '<%# DataBinder.Eval(Container.DataItem, "description")%>' runat="server" /> <br/><br /> <b> <asp:HyperLink ID="lblFeedback" runat="server" ForeColor="#0000ff" Text="Give Feedback"></asp:HyperLink></b> <b><asp:HyperLink ID="lblViewFeedback" runat="server" ForeColor="#993300" Text="View Feedback"></asp:HyperLink></b> <asp:Label visible = false id="lesson_plan_id" Text = '<%# DataBinder.Eval(Container.DataItem, "lesson_plan_id")%>' runat="server" /> <h5>This Lesson Plan has been viewed <asp:Label ID = "lblCounter" ForeColor = #cc6600 Text = '<%# DataBinder.Eval(Container.DataItem, "counter")%>' runat="server" />times
</h5> <hr width="100%" color="#006600" size="2"> </ItemTemplate> </asp:repeater></form></
body></
html>Everything was working fine and I could access anything, but I added another link within the repeater control, which I've marked in bold:
<asp:hyperlink ID="hpSubTitles" runat="server" ForeColor="#0000ff" Text="Click here to see more documents and resources for this lesson"></asp:hyperlink>
In the code benind, this is the only one I can't access (it gives me error saying hpSubTitles is undeclared. The code behind is as follows:
Imports
System.DataImports
System.Data.SqlClientImports
System.IOPublic
Class LessonPlan Inherits System.Web.UI.Page Dim countViewFeedback, countSubLessons As Integer Dim fb As New objFeedback.feedback Dim lp As New objLessonPlan.lesson_plan#
Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer.<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent() End Sub Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor.InitializeComponent()
End Sub#
End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim course_id As Integercourse_id =
CType(Request.Params("course_id"), Int32) Dim myCourse As objLessonPlan.lesson_plan = New objLessonPlan.lesson_plan() If Not Page.IsPostBack ThenrepeaterLessonPlans.DataSource = myCourse.GetAllLessonPlans(course_id)
repeaterLessonPlans.DataBind()
End If End SubThen I have the following procedure defined in which I'm trying to access the hpSubTitles along with other code that I didn't post since it's long and not relative to the error I'm getting. I'm just trying to set up the navigateUrl property for the hpSubTitles as shown below, but it doesn't let me.
Public Sub lesson_plan_onItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)
hpSubTitles.navigateUrl = "SubLessons.aspx?lesson_plan_id=" + lesson_plan_id.ToString End SubWednesday, March 29, 2006 1:48 PM -
User-1363174918 posted
This looks like VS 2003 style code behind file. Did you migrate your Web before using it in VS 2005?
First I notice that Partial keyword is missing before the class declaration. Partial is very important as it tells compiler that some declarations and code will be coming from elsewhere (such as from markup). Without partial control declarations won't be picked by intellisense. Here is how class looks when I create a new Web Form in VS 2005
Partial
Class LessonPlanInherits System.Web.UI.Page
End
ClassI think adding partial will fix the intellisense problem, but I would recommend migrating Web site to the VS 2005 model or installing Web Application Project add-on as there might be other issues as well. For instance, InitializeComponent is no longer used.
Wednesday, March 29, 2006 2:37 PM -
User-153404742 posted
Hi,
I actually created this application in 2005 version, and I changed the class to have Public because I was trying to test something. However, even though I had partial class, it still does not recognize the controls.
Wednesday, March 29, 2006 2:45 PM -
User-1363174918 posted
That's odd since only VS 2003 adds these:
<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE"> <meta content="JavaScript" name="vs_defaultClientScript"><meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
Anyway, try adding a new, empty, default page, drop a button on it and see if it is available for intellisense in the code file.
Wednesday, March 29, 2006 4:26 PM -
User-153404742 posted
Yes, any new page I create lets me access the controls and brings up the intellisense. It's just with any new controls I add on a current page. It's also weird that it works when I make the class Public and add the following line of code after the Inherits System.Web.UI.Page
Protected WithEvents hpSubTitles As New System.Web.UI.WebControls.HyperLinkWednesday, March 29, 2006 5:04 PM -
User-1363174918 posted
If you add explicit declaration, it will definitely work, but that is what partial class architecture is supposed to do. VS 2005 does not support code behind model using full classes (at least not out of the box - you'll need Web Application Project add-on). I would recommend creating a new Web for with code separation and moving code and element to the new page. Remember, you don't have declare them and you don't need initialize component and no need to add META elements from VS 2003.
Wednesday, March 29, 2006 5:34 PM -
User33167115 posted
Similar issue. I use .Net 2 (Visual Studio 2005) with Ajax 1.0 extensions.
I have a .aspx page. The controls are mostly "asp:label". They were created via manual typing in the .aspx (i.e. using "source" mode not "design" mode), via copy/paste from another .aspx page, and the control IDs then being edited for uniqueness. The asp:label fields sit inside <table> <tr> and <td> HTML tags, which are inside Ajax tabpanels. All of the asp and ajax controls have runat="server", and all are in a <Form> with runat="server".
I do not have a master page.
I have VB code-behind, referenced by the .aspx via: Page Language="vb" AutoEventWireup="false" CodeFile="WIP.aspx.vb" Inherits="WIP" The code-behind declares a partial class, inheriting from System.Web.UI.Page. The asp:label controls are all recognised in the code-behind i.e. intellisense works. But Visual Studio is also reporting each control as an error "Name xxx is not declared" in the "error" pane. Inconsistent - if a control isn't declared, then how does VS know its type, for intellisense to work? VS is also not underlining each reference to these controls as an error in the code-behind pane.The resulting project will not "build", presumanly because of the "errors". But the web page will run via "File>View in Browser". Note that the "Project > Properties > Web" settings specify to render pages using IIS, and the virtual IIS directory has been created.
If I copy the .aspx and .aspx.vb pages (via Windows Explorer) into a production IIS virtual directory, they run correctly. This verifies that the errors being reported are spurious.
If I explicitly declare each control in the code-behind (i.e. "Protected xxx As System.Web.UI.WebControls.Label") the name is then underlined, with error "xxx is already declared as System.Web.UI.WebControls.Label in this class" appearing via mouse-hover. The "name xxx not declared" error remains in the error pane however.
If I remove the reference to a label field from the code-behind, the entry in the "error" pane goes away, thereby showing the error pane is being rebuilt.
There appears to be a disconnect between the coding environment and the way VS is recognising its delcaration errors.
I created a clean new web page, and copy/pasted the source from the .aspx and .aspx.vb files, with no effect - the new page exhibits the same problem as the old. Switcihing between design and source mode has no effect. Closing/restarting VS has no effect. Rebooting has no effect. It is like VS knows the declarations are there from the .aspx page, but the thing that generates the error list does not.
Wednesday, October 10, 2007 7:10 PM -
User-1445576190 posted
YES BRUCE!
I'm having the exact same problem. And, like with you, no one is responding to my forum posts on the subject.
It must be a very rare problem that no one can reproduce, but it is really annoying!
Aaron
Thursday, November 1, 2007 1:12 PM -
User-959698707 posted
I've had some success under a couple of similar scenarios.
1. IntelliSense and page builds stopped working in the code-behind when referring to any new controls that I would add to the page. Visual Studio 2005 continued to treat previously-added older controls normally. This was my solution:
- create a new document+code-behind in a new sub-folder,
- copy code from the failing files .aspx and .vb files and paste to the new files,
- test the news files,
- rename the failing files to a backup name,
- move the new files to directory of the original files,
- rename the new files to the name of the original files.
I've tested this only once, however it did work like a charm.
2. Intellisense failed with "Element 'x' is not a known element. This can occur if there is a compilation error in the Web site." when using any of Peter Blum's Professional Validation And More (“VAM”) controls after installing his assembly into the web application. The problem appeared to relate to accessing the development site over a network share. VS Intellisense would break on the new assembly and the local ASP.NET Development Server would throw the following two exceptions. (The IIS6 server where the site was located served up pages without error.)
System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
Exception type: VerificationException | Exception message: Operation could destabilize the runtime.
The solution to the above two exceptions was to grant FullTrust to the web site share for the development server using Microsoft .NET Framework Configuration as outlined in this KB article: http://support.microsoft.com/kb/320268
Then, to restore Intellisense on the affected controls, I deleted the cached schema files for control markup Intellisense that VS maintains. This is done by deleting all files in this directory:
c:\Documents and Settings\[YourUserName]\Application Data\Microsoft\VisualStudio\8.0\ReflectedSchemas
Many thanks to Scott Guthrie for this article @ http://weblogs.asp.net/scottgu/archive/2006/11/16/gotcha-lost-html-intellisense-within-asp-net-ajax-controls.aspx#1269028I hope this helps...
Thursday, November 8, 2007 7:42 PM - create a new document+code-behind in a new sub-folder,
-
User-1445576190 posted
It's weird that something as low-tech as this works.
You don't even have to create a new folder. Just created a new webform and codebehind, copy the code from the original files, exclude the original files, build it. Then rename the new files to the original file names, making sure to match the partial class name in the codebehind to the Inherits attribute of the Page dirfective. That's it.
Thank you for posting this.
Aaron
Friday, November 16, 2007 12:25 AM -
User-959698707 posted
Happy to assist!
--Mark
Friday, November 16, 2007 1:23 AM -
User-160449870 posted
This solution works for "the control is not found" false error report in Visual Studio
I built a web site with around thirty pages. Several months ago I added some controls to an existing page and after compiling the website I started recieving an error listing for each control that I had added to the page. It stated "Name "ControlWhateverTxt" is not declared". I knew that this was a compiler error because 1) The webpage would run and utilize the controls in spite of the reported error 2) When I deleted the controls I would recieve a different error... and 3) I noticed that I recieved the error from any and all controls that I drug onto the page from the toolbox from a certain point of time forward. The controls declared previous to this time remained had no problems of thsi nature. My first tack was to delete the controls and drag new ones over from the tool box - same error. Next I stripped the code out of the .aspx and aspx.vb files and pasted them into new files with new names. When I recompiled the program it continued to report errors in the original files BUT NOT the cloned files, which confirmed to me that some kind of compiling data visual studio was keeping behind the scenes had become corrupt for the broken page. Satisfied that I had solved the problem I renamed the original files to archive them, and then renamed the cloned files to the names of the originals and viola - the bug came back! I messed around with some other things and finally gave up and lived with the false compiler errors for several more months until they became such a problem debugging other pages that I was forced to deal with them. I finally found a solution that worked from one of the many posts on the internet. I felt compelled to re-post it here because it is critical the at steps below are taken in the exact order they are listed. Here is the work around in black and white.
1) Create a NEW WebForm (naming it "OrginalPageName_2" is helpful)
2) Copy the HTML code from the original .aspx file to the new blank .aspx file - do the same with the aspx.vb code behind file.This is kind of 101 but make sure that you don't overwrite the first line in the new .aspx file when you paste the original code to it - in other words copy everything from the second line down in the transfer because the first line of code syncs the newly created page to it's code behind page.
but leave this! <%
@ Page Language="VB" AutoEventWireup="false" CodeFile="OriginalPageName_2.aspx.vb" Inherits="OriginalPageName_2" %>also along the same lines when you copy the code behind file from the orignal aspx.vb file to the new aspx.vb file - confirm that the "Partial Class" declaration matchs the "Inherits=" parameter of the new .aspx file. If you have pasted over it with the code from the original file you will have to rename it back to what it was.
3) HERE IS THE CRUX OF THIS WORK AROUND! DO NOT rename the original files first and try to save them and then rename the new ones! If you need to save the original files go to windows explorer and make a copy of them in a ANOTHER FOLDER OUTSIDE OF YOUR WEBSITE. Then go back to Visual Studio and DELETE the original .aspx file using the SOLUTION EXPORER. This will automatically take out the aspx.vb code behind file and MORE IMPORTANTLY this seems to remove the corrupt debbuging information associated with the file name from the compiler. Once the original files ARE GONE you can rename the new clones to the original names and the compiler will create a NEW SET of behind the scenes status files for the web page that no longer report false bugs for files of that name. If for some reason that page or some other one becomes permenantly corrupted again you now know what to do.
There is supposed to be some kind of patch for this floating around. I installed several service packs and they didn't fix it though...
Whew! - Bugs like this in the compiler are aggravating and expensive to developers. - this one cost me several thousand dollars in diverted development time... I would like to thank mdrols from this forum who took the time to share the solution above more or less the way I presented it. I re-posted his solution because I had actually tried a variation of it previously and it didn't work for me because the SEQENCE IS ABSOLUTELY CRITICAL.
I must have read at least fifty posts about this bug and he was the only one that cracked it. His effort motivated me to stop what I was doing and help the next guy down the line like he did. While I was writing this post It hit me that about half of the solutions I find to problems come from these posts. If you think about it, it's pretty amazing that anyone stops to post a solution to a problem on the net because it takes time, which in most cases is development money. I guess if you work for someone else then it is their nickel, but even then it's still takes some effort... It's Christmas and I wouldn't wish this bug on anyone! Thanks mdrols - you Da man!
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Saturday, November 24, 2007 11:46 AM -
User-160449870 posted
Getting rid of the false compile errors buy replacing the file they were refering to seemed to have made the site compile significantly faster. About the time this bug originally appeared the compiler seemed to start to drag during compilations and crash a lot. It may be my imagination but it seems that the web pages themselves are running faster after fixing this problem...
Saturday, November 24, 2007 12:07 PM -
User-1320770751 posted
Do you just want to re-direct to another page?
Try something like this:
.
<p><a href="LessonPlans.aspx">Click here to view the Lesson Plans</a><p>
You can put this in your codebehind. I will look like normal hyperlink.....
I did not read through Each article, but if you are only trying to redirect a page, then id suggest to do it this way.... otherwise
in the hyperlink's click event type response.redirect("LessonPlan.aspx")
If you would like to pass a variable with the page.....response.redirect("LessonPlan.aspx?LP_id=" & Lesson_plan_id)
I hope I understood correctly - and that this helps in anyway
Monday, December 3, 2007 9:08 AM -
User1156397607 posted
- create a new document+code-behind in a new sub-folder,
- copy code from the failing files .aspx and .vb files and paste to the new files,
- test the news files,
- rename the failing files to a backup name,
- move the new files to directory of the original files,
- rename the new files to the name of the original files.
Great post mdrols, that fixed my problem also.I'm using VS 2008, and spent quite a while trying to fix this bug (and searching the web for things to try).
Thursday, March 6, 2008 11:24 AM - create a new document+code-behind in a new sub-folder,
-
User-1813351543 posted
Hi.
Thanks for the detailed instructions. I tried this to no avail (tho' will retry).
I was wondering if you compared the BEFORE and AFTER <STRIKE>web.configs</STRIKE> (oops ... head had moved on while hands still typing !) vbroj file ? Other reading around this indicates that it may have something to do with it.
Regards.
Wednesday, July 9, 2008 10:22 AM -
User2009432164 posted
What the heck! It's a year on, a major version release on, and a service pack on and this dng bug is still out there.
It was bad enough when MS made you buy new versions just to get bug fixes but when the bugs don't even get fixed. ...
Thursday, August 28, 2008 3:17 PM -
User483756418 posted
Yeah. What a stupid and low tech solution. Worked a treat however. Thanks for posting it.
Thursday, October 1, 2009 8:03 PM -
User1325989893 posted
I found that I got this error using old project files from VS2008 going into VWD2008, the way to fix it was to delete the project completely, create a new project and import all of the files from the original. As a default.aspx was created in the new project it caused errors in the new build even though I replaced it but once these were sorted it built fine. It was driving me crazy.
Tuesday, October 6, 2009 12:15 PM -
User-1010534986 posted
This problem had me quite baffled for ages. My particular case was further confused by the fact that I had a MasterPageFile in play and my partial class .vb was not inherting from System.Web.UI.Pge, rather I had a custom cass as my base. Anway, project was running fine within VS2008 (yes, I know all of the discussions have been with regard to VS2005) and in IIS6 also, but if I tried to compile the site either using the command line compiler or the Rebuild Web Site menu option, I would get a great stack of 'is not declared' errors.
My solution was this: I excluded the problematic files (there were three of them producing errors. I just right-clicked them in Solution Explorer and chose 'Eclude from project'), rebuilt the site successfully, re-included the problem files and rebuilt once again. Success!
This may have been a question of temporary files in play, but I couldn't find the temporary asp.net files folder in the usual place so I was stuck there. Anyway, I hope this simple fix helps somebody else.
Wednesday, January 6, 2010 12:07 AM -
User1500421890 posted
I spent a lot of time trying to find an answer to this. In my case I had two problems:
1. Outdated AJAXControl Toolkit. I was using version 1.0. I deleted the old DLL from the bin folder, removed all toolbox controls, downloaded the updated AJAXControl toolkit (for 3.5), unzipped, added the new controls to the toolbox, then dragged and dropped a new control on to the page. The error then disappeared and the designer file was automatically populated with all the controls on the page.
2. I had an earlier problem to do with misspelling of a control property. In my label control, I had used 'class' instead of 'cssClass'. I read somewhere that spelling errors can cause this same problem to occur.
Hope this helps someone.
Thursday, July 8, 2010 1:26 AM -
User883827074 posted
I'm new at writing asp.net code, so I frequently run into puzzles like this because I haven't yet developed the habits required to avoid weird stuff in VS (2008). I don't know why this trick works, but it worked for this exact problem and a few others. I go to first line on the the aspx file, and simply insert a line break (plus a tab on the second line to make it look better), so the @ Page declaration occupies 2 lines. In this case, I closed the project, re-opened it, and contols were recognized in the code-behind file.
Edit to post: I spoke too soon. This trick allowed intellisense to return, but the compile error stubbornly remained. I ended up using the work-around posted 11-24-2007 04:46 PM.
Wednesday, November 23, 2011 4:08 PM -
User1423911570 posted
It's also weird that it works when I make the class Public and add the following line of code after the Web.UI.Page
http://www.stopfinger.com/goods_c3BlY19pZAk1ODY4.htmlThursday, November 24, 2011 3:52 AM -
User-520257323 posted
Thank you -- during copy-over from one solution to another in VS2017 had a similar problem with an id'd span reference. This took care of it -- Thank you so much!!
Thursday, June 28, 2018 10:13 AM -
User-888405463 posted
I know it has been over ten years, but pgedney's post still helped me. While suffering the EXACT symptoms listed by Bruce and working through pgedney's solution, I figured out that another separate aspx file was referencing the the codebehind file of the original aspx page. This was causing all sorts of errors in the original aspx file's codebehind (losing references to all of the controls). I was able to resolve the issue by simply deleting the separate aspx and associated codebehind files which were referencing the incorrect vb file as (in my case) this page was unneeded. After that, the build worked.
Friday, August 23, 2019 4:49 PM