• 7/4/2013

    (English) The name 'InitializeControl' does not exist in the current context Controles utilisateur, SharePoint 2013 and Ressources

    This article is written for SharePoint developers who already developed multilingual webparts.

    It is a good practice to localize an application when you develop for SharePoint, which will make the adding of a new language easier.

    When we developed for SharePoint 2010 we used to put resources files in hive/config/resources (and then run a stsadm –o copyappbincontent or automate it via a timerjob when activating features)

    Or we used to create an empty SharePoint solution element in which we added our files and indicated that the deployment target was the appglobalresources folder (see for more details)

    When SharePoint beta came out, and after the RTM with development tools, we all rushed (or maybe only me?) to test all that we knew on SharePoint 2010 under 2013 to see if it had changed. And we all faced this error message “The name 'InitializeControl' does not exist in the current context” when using resources in a visual webpart.

    In fact, Microsoft apparently changed the way of building visual webparts in farm solutions with 2013 tools, it is now built the same way as visual webparts in sandboxed solutions. And if you remember we had a lot of troubles with these webparts.

    Update 1 came ou, nothing changed, then march update, same thing, update 2 neither. And the final version of SharePoint 2013 development tools came out!

    Surprise! If we delete and recreate our webpart (same code) the error message changes to « the name « resource » does not exist in the current context ».

    After many tries I ended finding a correct workaround to the problem. You only need to create a separate user control in a folder mapped to hive/templates/controlstemplates, then create a classic webpart, register the namespace of your user control as safe (with the element of the webpart for example) and to edit the code of the webpart.

    public class WebPart1 : WebPart


            private const string _ascxPath = @"~/_CONTROLTEMPLATES/15/NameofUserControl.ascx";


            protected override void CreateChildControls()


                Control control = Page.LoadControl(_ascxPath);




    Your solution should look like this by the end


    I think that Microsoft is trying to simplify developers’ lives adding a resources check at compilation time, but it does not seem yet ready.

    PS: in this article I was only treating web resources of SharePoint, remember you also have resources that you used to deploy to hive/resources, for example for workflows, it most probably has changed too but I have not check yet.