【发布时间】:2015-01-11 03:25:28
【问题描述】:
已解决。继续阅读...
我可以从MSDN aricle 1:1 复制代码,但它不起作用。 我在 Web 部件属性中看不到任何自定义属性。 虽然没有“杂项”类别。只有外观、布局和高级。
namespace Tts.CareersPortal.Web.CareersPortal.Fn.WebParts.NewContactTeaserWebPart
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using MyNameSpace.NewContactTeaserWebPart;
public partial class NewContactTeaserWebPartUserControl : UserControl
{
private int _contactTeaserCount;
[Category("Extended Settings"),
Personalizable(PersonalizationScope.Shared),
WebBrowsable(true),
WebDisplayName("Sample Text"),
WebDescription("Please Enter a Sample Text")]
public int ContactTeaserTeaserCount
{
get
{
return _contactTeaserCount;
}
set
{
_contactTeaserCount = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
IEnumerable<MyContact> contacts = LoadContactProperties();
Repeater1.DataSource = contacts;
Repeater1.DataBind();
}
private IEnumerable<MyContact> LoadContactProperties()
{
ContactFinder contactFinder = new ContactFinder(ContactTeaserTeaserCount);
IEnumerable<MyContact> result = contactFinder.GetContact();
return result;
}
}
}
解决方案:我将 Web 部件属性添加到错误的类文件中:-/ 您必须将其添加到 Web 部件 - 而不是用户控件。要将 webpart 属性传递给用户控件,我推荐 this 以下方法 - 其他方法也可以。
不起作用。有什么想法吗?
【问题讨论】:
标签: sharepoint web-parts