我是共享點的新手。我不知道這是否可行。 我有兩個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);
}
}
當我嘗試設置的連接,它不同時顯示,但只設置主題連接。