Click here to Skip to main content
15,891,904 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
The application is created in 'VS 2010 Ultimate' website model. My operating system is 'Windows 7 Professional'

which is 64 bit. I have installed SP1 also. During compilation i am getting below errors-

'Textbox' or label is not declared. It may be inaccessible due to its protection level.

Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

Even the text box, label or button exists on aspx page, compiler is not recognising the controls while compiling. Intellisence is working in code behind file for controls.

Please let me know what i am missing.

The application is running successfully on client machine.

I searched over net and found that installing VS 2010 SP1 will correct the error. I have installed the same but no success. Some one suggests that installing the hot fix KB981167 will correct the error . I tried to install the patch KB981167 but getting error as “KB981167 does not apply, or is blocked by another condition on your computer.”.
Posted
Updated 26-Sep-12 2:32am
v4
Comments
Ankur\m/ 26-Sep-12 4:32am    
Can you update your question with the code where you get this error? Also add the html code where you have declared it.
Ajay1242 26-Sep-12 5:18am    
It is a big application which is compiling successfuly at client machine. I am using CodeFile. I have checked that wverything is ok from perspective of codefile or inherits in code file. I am using website model so there is no designer file for aspx and the class in code file is partial.
Ankur\m/ 26-Sep-12 5:39am    
I could think of 2 things:
i) Incorrect designer code.
ii) You are using template control. You will need to use FindControl to find a control inside it.
Timberbird 26-Sep-12 4:38am    
May be caused by many reasons - usually it's related to the code-behind model. Do you use CodeFile instead of CodeBehind? Is you textbox included in .designer file? Code and markup would help
Ajay1242 26-Sep-12 5:18am    
It is a big application which is compiling successfuly at client machine. I am using CodeFile. I have checked that wverything is ok from perspective of codefile or inherits in code file. I am using website model so there is no designer file for aspx and the class in code file is partial.

make sure that you declare texbox and lables under the <body> tag..

due to this above error is occurd
 
Share this answer
 
v2
Comments
Ajay1242 26-Sep-12 8:09am    
Controls are under body tag. The application is running successfully on client machine.
dilipkamalon 12-Jan-14 8:17am    
I am using VS 2008 , i closed and open the project suddenly all the controls in my projects is displaying as 'Not declared.' . I closed and reopened, restarted widows, created new form and copied the code . None of them are working. Please give me a correct solution for this.
Member 10411196 14-Jun-15 14:47pm    
My Friend , Make sure that you added (runat = "server") in the declaration of Text
Hi,

Go to page design (Default.aspx.designer.vb) and declare as below.

Protected WithEvents txtName As Global.System.Web.UI.WebControls.TextBox

Thanks,
Fadao
 
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