元素' usercontrol'不是已知的元素--Sharepoint Webpart

时间:2016-12-14 22:14:33

标签: asp.net sharepoint user-controls web-parts

我正在尝试将用户控件插入Sharepoint Visual Webpart。 它甚至不适用于空的webpart项目。我得到了这个错误加上'" initializeControl'没有声明'

Webpart和Usercontrol都是同一个项目的一部分。

在我尝试将其放在WebPart上之前,控件已正确部署到C:\ Program Files \ Common Files \ Microsoft Shared \ Web Server Extensions \ 14 \ TEMPLATE \ CONTROLTEMPLATES \ Myproject

我尝试了所有可以Goolge的东西,从更改web.config文件到尝试每个可能的其他解决方案,网上都有。

我没有Usercontrol的所有其他webpart都正常工作。奇怪的是,Usercontrol在Webparts设计视图中呈现。

这是指向显示我的问题的小视频的链接。帮助我,我很绝望 https://www.youtube.com/watch?v=bHoVR1s_JF8&t=25s

(注意:使用Windows 7和Visual Studio 2015创建Sharepoint 2010应用程序)

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" />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<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" />

用户控制代码

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

我在webpart中包含usercontrol后得到的第一个错误是 &#34;文件&#39; / _ controltemplates / TEXTVWPUC / TESTUC.ascx&#39;不存在。&#34;保存项目后。

我得到&#34;元素&#39; TESTUC&#39;不是一个已知的元素。如果网站中存在编译错误,或者缺少web.config文件,则会发生这种情况。&#34;。

最后&#34;&#39; InitializeControl&#39;没有宣布。由于其保护级别,它可能无法访问。&#34;因为webpart ascx.g文件被删除。

从Web部件中删除控件后,所有错误都会消失。我在网上尝试了十几种解决方案,包括IIS重置。什么都行不通。我正在考虑重新安装VS 2010

0 个答案:

没有答案