0

ユーザーコントロールを読み込むWebパーツを作成する必要があります。 私が見つけたすべての回答は古くなっているか動作していません。ユーザーコントロールを読み込むSharePoint 2013 Webパーツを作成する

私は、Visual Studio 2015とSharePoint 2013 を使用してい

すべてのヘルプ...私は、Webパーツと私のユーザーコントロールおよびその他でプロジェクトを作成したが、私はそれらをリンクする方法がわかりません? おかげ

答えて

0

あなたのWebパーツは、Visual Webパーツではない場合、あなたは(WebパーツCSファイルで)このようにユーザーコントロールを読み込むことができます。

namespace ProjectName.Folder.Custom_Webpart 
{ 
    [ToolboxItemAttribute(false)] 
    public class Custom_Webpart : System.Web.UI.WebControls.WebParts.WebPart 
    { 
     private const string _ascxPath = @"~/_CONTROLTEMPLATES/15/ProjectName/Folder/Custom_UserControl.ascx"; 

     protected override void CreateChildControls() 
     { 
      var control = Page.LoadControl(_ascxPath) as Custom_UserControl; 
      //this.ChromeType = PartChromeType.None; 
      Controls.Add(control); 
     } 
    } 
} 

あなたのWebパーツは、Visual Webパーツの場合は、ユーザーコントロールを読み込むことができますwebpart .ascxファイルに次の手順を挿入してください。

<%@ Register Src="/_controltemplates/15/ProjectName/Folder/Custom_UserControl.ascx" TagPrefix="Custom" TagName="CustomControl" %> 

<Custom:CustomControl runat="server" /> 
+0

お返事ありがとうございます。私はそれを試みます。 – nunonaos

+0

特定の場所にユーザーコントロールプロジェクトを展開する必要はありますか? – nunonaos

+0

カスタムユーザーコントロールは、SharePointのマップされたフォルダー(CONTROLTEMPLATES)に展開する必要があります。こちらをご覧ください:https://blogs.msdn.microsoft.com/vssharepointtoolsblog/2010/03/12/deploying-files-using-mapped-folders/ – Cecilia

関連する問題