In Visual Studio 2012, when you are working with a visual web part, your user control's ascx.g.cs file becomes empty. So you get an error "The name ‘InitializeControl’ does not exist in the current context".
This is reported as a bug in visual studio 2012 and it generally happens when your server side mark up is having issues. This ONLY happens when you are editing your ascx file.
You can try following:
- try to undo some of the last changes in ascx file.
- Create copy of ascx file and revert it from source control. Rename g.cs to g.txt and switch to ascx and hit save. That will generate another g.cs with correct content
- Please check the @Register declarations against the TagPrefix and TagName that you are using.
- Try to comment out all controls in ascx and save it. That will generate ascx.g.cs along with content again. Now start un-commenting the controls one by one.
- In worst cases, after trying lots of things people also switch to new web part and migrate useful code from the problematic web part step by step to resolve the error.