I am trying to insert a user control into a Sharepoint Visual Webpart. It doesn't even work with an empty webpart project. I get this erro plus the ''initializeControl' is not declared'
Both the Webpart and the Usercontrol are part of the same project.
The control is correctly deployed to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\CONTROLTEMPLATES\Myproject before I try to put it on the WebPart
I tried everything I could Goolge, from changing the web.config file to trying every possible other solution there is out there on the net.
All my other webparts without Usercontrol are working fine. Strangely enough, the Usercontrol is rendered in the Webparts design view.
Here is a link to a small video showing my problem. Help me, I am desperate https://www.youtube.com/watch?v=bHoVR1s_JF8&t=25s
(Note: Using Windows 7 with Visual studio 2015 to create Sharepoint 2010 apps)
Usercontrol ascx
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="VB" AutoEventWireup="true" CodeBehind="TESTUC.ascx.vb"
Inherits="TEXTVWPUC.ControlTemplates.TEXTVWPUC.TESTUC" %>
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
<br />
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:CheckBox ID="CheckBox1" runat="server" />
Webpart ascx
<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="VB" AutoEventWireup="true" CodeBehind="VWP.ascx.vb" Inherits="TEXTVWPUC.VWP" %>
<%@ Register src="../_controltemplates/TEXTVWPUC/TESTUC.ascx" tagname="TESTUC" tagprefix="uc1" %>
<uc1:TESTUC ID="TESTUC1" runat="server" />
Usercontrol code
Imports System
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Namespace ControlTemplates.TEXTVWPUC
Partial Public Class TESTUC
Inherits UserControl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
End Sub
End Class
End Namespace
First error I get after including the usercontrol in my webpart is "The file '/_controltemplates/TEXTVWPUC/TESTUC.ascx' does not exist." after saving the project.
After I get "Element 'TESTUC' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing.".
Finally "'InitializeControl' is not declared. It may be inaccessible due to its protection level." as the webpart ascx.g file gets deleted.
After removing the control from the web part all errors disappear. I tried a dozen of solutions proposed on the net, including IIS reset. Nothing is working. I am thinking of reinstalling VS 2010