Problem Description

Following are some issues observed while developing Visual Web Parts for SharePoint 2013 using Visual Studio 2012

  • Any changes made to the HTML markup are not reflected on the site
  • Build errors like 'The name InitializeControl does not exist in the current context'


These errors/issues are caused because of the custom tool called 'SharePointWebPartCodeGenerator' which is used on the visual web part's user control file. All markup changes made to the user control are processed by this custom tool, to include all the design and markup elements in the DLL. In SharePoint 2013, the user control is not copied to the file system.
The errors described above turn up due to some configuration issues of this custom tool. Follow the below steps to solve these errors.

  • Make sure the 'Site Url' property of your visual studio project is set to a valid SharePoint site's url. Make sure this site is accessible.
  • Check if the value of custom tool for the user control is set to 'SharePointWebPartCodeGenerator'. Follow the below steps.
    • Select the user control from your 'Solution Explorer', and click F4 to show the properties of the user control.
    • In the properties window, check the value for 'Custom Tool'.
    • It should be set to 'SharePointWebPartCodeGenerator'. If not please set this value and save this.
  • Manually run the custom tool.
    • From the solution explorer, right click on the user control of your visual web part and click on 'Run Custom Tool'.
    • Rebuild and deploy the web part.

Now the changes made to the visual webpart should reflect and work fine after deploying it.