我是共享点的新手。我不知道这是否可行。 我有两个Web部件,其中一个有两个值,我需要传递给第二个Web部件。 有没有办法做到这一点,或者我只能有一个连接/ 谢谢共享点中两个Web部件之间的多个连接
我有两个可视的Web部件。在提供者中,我有两个下拉列表,我需要将值传递给消费者。以下是代码:
public interface IMyConnection int AreaId {get; } int TopicId {get; }}
public class Provider : WebPart, IMyConnection
{
private Control control;
protected override void CreateChildControls()
{
control = Page.LoadControl(_ascxPath);
Controls.Add(control);
base.CreateChildControls();
}
public int AreaId
{
get { return 1; }
}
public int TopicId
{
get { return 2; }
}
[ConnectionProvider("TopicId", "TopicId", AllowsMultipleConnections = true)]
public IMyConnection SetTopicConnection()
{
return this;
}
[ConnectionProvider("AreaId", "AreaId", AllowsMultipleConnections = true)]
public IMyConnection SetAreaConnection()
{
return this;
}
}
public class Consumer : WebPart
{
private IMyConnection connection;
private Control control;
protected override void CreateChildControls()
{
control = Page.LoadControl(_ascxPath);
Controls.Add(control);
}
[ConnectionConsumer("TopicId", "TopicId", AllowsMultipleConnections = true)]
public void GetTopicConnection(IMyConnection theConnection)
{
connection = theConnection;
}
[ConnectionConsumer("AreaId", "AreaId", AllowsMultipleConnections = true)]
public void GetAreaConnection(IMyConnection theConnection)
{
connection = theConnection;
}
protected override void RenderContents(HtmlTextWriter writer)
{
if (connection != null)
{
//do work
}
base.RenderContents(writer);
}
}
当我尝试设置的连接,它不同时显示,但只设置主题连接。