Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VS2010 VB.NET
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 25-Sep-12 23:29pm
Edited 26-Sep-12 3:32am
v4
Comments
Ankur\m/ at 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 at 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/ at 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 at 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 at 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.
Ajay1242 at 26-Sep-12 5:17am
   
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.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

make sure that you declare texbox and lables under the <body> tag..
 
due to this above error is occurd
  Permalink  
v2
Comments
Ajay1242 at 26-Sep-12 8:09am
   
Controls are under body tag. The application is running successfully on client machine.
dilipkamalon at 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.

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

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 130
4 DamithSL 105
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 5 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100