Error: label does not exist in current context
I have MyPage.aspx which have number of controls, it was working fine, till the point I made heavy changes. After making lot of changes to MyPage.aspx, when i tried to compile project, it started giving me error: label does not exist in current context. The problem here was my label control was there on .aspx page, but it was still giving me error at compile time.
Few things I tried which didn't worked
- Try to switch design view and source view of MyPage.aspx
- Tried to comment control and try to create same control again.
- Delete designer file (Eg: MyPage.aspx.designer.cs)
- Try to recreate designer file.
- delete MyPage.aspx.designer.cs file, now right click on MyPage.aspx and select "Convert to web application" it will create new MyPage.aspx.designer.cs file.
- At this point when I tried to create designer file i received error, unable to create designer file due to improper html. After i rectified html on MyPage.aspx and follow the same steps to create designer file, it have created MyPage.aspx.designer.cs
- Finally my project gets compiled.