Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here are simple provider and consumer Web Parts. The provider UI accepts a text field that it passes to the consumer Web Part which simply outputs it. The connection between the Web Parts is the following interface:</p> <pre><code>namespace ConnectedWebParts { public interface IParcel { string ID { get; } } } </code></pre> <p>The Provider Web Part implements this interface and must have a method with the attribute ConnectionProvider that returns itself (since it implements the interface):</p> <pre><code>namespace ConnectedWebParts { public class ProviderWebPart : WebPart, IParcel { protected TextBox txtParcelID; protected Button btnSubmit; private string _parcelID = ""; protected override void CreateChildControls() { txtParcelID = new TextBox() { ID = "txtParcelID" }; btnSubmit = new Button() { ID = "btnSubmit", Text="Submit"}; btnSubmit.Click += btnSubmit_Click; this.Controls.Add(txtParcelID); this.Controls.Add(btnSubmit); } void btnSubmit_Click(object sender, EventArgs e) { _parcelID = txtParcelID.Text; } [ConnectionProvider("Parcel ID")] public IParcel GetParcelProvider() { return this; } string IParcel.ID { get { this.EnsureChildControls(); return _parcelID; } } } } </code></pre> <p>The Consumer Web Part must define a method with a ConnectionConsumer attribute that accepts an object that implements the connection interface (the provider Web Part) as a parameter:</p> <pre><code>namespace ConnectedWebParts { public class ConsumerWebPart : WebPart { protected IParcel _provider; protected Label lblParcelID; protected override void CreateChildControls() { lblParcelID = new Label(); if (_provider != null &amp;&amp; !String.IsNullOrEmpty(_provider.ID)) lblParcelID.Text = _provider.ID; this.Controls.Add(lblParcelID); } [ConnectionConsumer("Parcel ID")] public void RegisterParcelProvider(IParcel provider) { _provider = provider; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload