Click here to Skip to main content
15,913,941 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a question. I click on build, build solution i get a list of errors in the Error List. The error is: The name 'TextBoxRes' does not exist in the current context. Why is this happening? I checked the properties for the textboxes and the names are spelled right. I debugged the program and it runs fine. Why am I getting these errors for? Is there a way to fix them?

CSS
Error   4   The name 'ButtonPrint' does not exist in the current context    C:\Documents and Settings\Administrator.SACS-COC\my documents\visual studio 2010\Projects\SACSCOCLogin1.1\SACSCOCLogin1.1\SchoolReports.aspx.cs 17  9   SACSCOCLogin1.1
Error   5   The name 'ButtonPrint' does not exist in the current context    C:\Documents and Settings\Administrator.SACS-COC\my documents\visual studio 2010\Projects\SACSCOCLogin1.1\SACSCOCLogin1.1\FTEEnrollmentInformation.aspx.cs  18  9   SACSCOCLogin1.1
Error   6   The name 'ButtonPrint' does not exist in the current context    C:\Documents and Settings\Administrator.SACS-COC\my documents\visual studio 2010\Projects\SACSCOCLogin1.1\SACSCOCLogin1.1\FinancialProfileFormC.aspx.cs 19  9   SACSCOCLogin1.1
Error   7   The name 'ButtonPrint' does not exist in the current context    C:\Documents and Settings\Administrator.SACS-COC\my documents\visual studio 2010\Projects\SACSCOCLogin1.1\SACSCOCLogin1.1\FinancialProfileFormD.aspx.cs 19  9   SACSCOCLogin1.1
Error   8   The name 'ButtonPrint' does not exist in the current context    C:\Documents and Settings\Administrator.SACS-COC\my documents\visual studio 2010\Projects\SACSCOCLogin1.1\SACSCOCLogin1.1\FinancialProfileFormA.aspx.cs 19  9   SACSCOCLogin1.1
Error   9   The name 'TextBoxEA' does not exist in the current context  C:\Documents and Settings\Administrator.SACS-COC\my documents\visual studio 2010\Projects\SACSCOCLogin1.1\SACSCOCLogin1.1\IALORegistration.aspx.cs  19  85  SACSCOCLogin1.1
Error   10  The name 'Label1' does not exist in the current context C:\Documents and Settings\Administrator.SACS-COC\my documents\visual studio 2010\Projects\SACSCOCLogin1.1\SACSCOCLogin1.1\FormAPublic.aspx.cs   20  13  SACSCOCLogin1.1
Error   11  The name 'Label1' does not exist in the current context C:\Documents and Settings\Administrator.SACS-COC\my documents\visual studio 2010\Projects\SACSCOCLogin1.1\SACSCOCLogin1.1\DBPage.aspx.cs    20  13  SACSCOCLogin1.1
Error   12  The name 'Label1' does not exist in the current context C:\Documents and Settings\Administrator.SACS-COC\my documents\visual studio 2010\Projects\SACSCOCLogin1.1\SACSCOCLogin1.1\FormCPrivateNon.aspx.cs   20  13  SACSCOCLogin1.1
Error   13  The name 'Label1' does not exist in the current context C:\Documents and Settings\Administrator.SACS-COC\my documents\visual studio 2010\Projects\SACSCOCLogin1.1\SACSCOCLogin1.1\FormDPrivateFor.aspx.cs   20  13  SACSCOCLogin1.1
Error   14  The name 'Label1' does not exist in the current context C:\Documents and Settings\Administrator.SACS-COC\my documents\visual studio 2010\Projects\SACSCOCLogin1.1\SACSCOCLogin1.1\CEOPage.aspx.cs   21  13  SACSCOCLogin1.1
Error   15  The name 'TextBoxEA' does not exist in the current context  C:\Documents and Settings\Administrator.SACS-COC\my documents\visual studio 2010\Projects\SACSCOCLogin1.1\SACSCOCLogin1.1\SubmitPage.aspx.cs    21  93  SACSCOCLogin1.1
Error   16  The name 'TextBoxEA' does not exist in the current context  C:\Documents and Settings\Administrator.SACS-COC\my documents\visual studio 2010\Projects\SACSCOCLogin1.1\SACSCOCLogin1.1\SubmitPage.aspx.cs    22  90  SACSCOCLogin1.1
Error   17  The name 'TextBoxEA' does not exist in the current context  C:\Documents and Settings\Administrator.SACS-COC\my documents\visual studio 2010\Projects\SACSCOCLogin1.1\SACSCOCLogin1.1\SubmitPage.aspx.cs    23  91  SACSCOCLogin1.1
Error   18  The name 'lblINST_ID' does not exist in the current context C:\Documents and Settings\Administrator.SACS-COC\my documents\visual studio 2010\Projects\SACSCOCLogin1.1\SACSCOCLogin1.1\SchoolReports.aspx.cs 24  9   SACSCOCLogin1.1
Error   19  The name 'DropDownListSchools' does not exist in the current context    C:\Documents and Settings\Administrator.SACS-COC\my documents\visual studio 2010\Projects\SACSCOCLogin1.1\SACSCOCLogin1.1\SchoolReports.aspx.cs 24  27  SACSCOCLogin1.1
Posted
Updated 25-Sep-13 4:15am
v2
Comments
Richard C Bishop 24-Sep-13 16:25pm    
That usually means you are referencing the object out of scope.
Computer Wiz99 24-Sep-13 16:28pm    
What I did was I have to start over with the project. I started a new project and I named it something else. Then I just added the forms from another project to the new one. Did that start the errors?
Richard C Bishop 24-Sep-13 16:29pm    
Probably, those controls won't exist in the designer of the project.
Computer Wiz99 24-Sep-13 16:31pm    
Ok. So I will have to delete the current ones and add them again?
Richard C Bishop 24-Sep-13 16:32pm    
Just try one and see if that fixes one. If it does, you will know what was the issue.

Your code refers to a couple of controls that are not available. For example your page SchoolReports.aspx has a code behind file SchoolReports.aspx.cs which refers to a ButtonPrint control.

The error (the first one of the list) tells you that the button ButtonPrint does not exist on the page SchoolReports.aspx.
 
Share this answer
 
Comments
Computer Wiz99 25-Sep-13 8:43am    
Eduard Keiholz, Ok. I tried changing one and the same error comes up. Like I said before the app debugs fine. It works when I view it in the browser and when I debug it. When I build the solution is when I get the errors. I also cleaned the solution and the errors went away until I build it or rebuild it again.
Ok. I solved this myself. Here is the steps I did.

SQL
1. Run at server

To access the HTML element as a variable in the C# code, the following value must be placed in the HTML element tag in the aspx file:

runat="server"

Some objects in the Toolbox in the Visual Studio IDE do not automatically include this value when added to the page.


CSS
2. Regenerate the auto-generated C# file:

    In the Solution Explorer, under the aspx file there is another file *.aspx.cs. Right-click on the parent aspx file. In the pop-up menu, select Convert to Web Application. Click on Build, Build Solution. All the errors are gone. 

Now the element should be accessible in the C# code file.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900