Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I just went through that process and this is how I managed to have it run on under a sandbox solution and also a 365 site, this is the entire sample code:</p> <p>Note: I'm using Visual WebPart (SandBoxed) within SharePoint Power Tools for Visual Studio</p> <p>ToolPartTest.ascx:</p> <pre><code>&lt;h3&gt;Selected List&lt;/h3&gt; &lt;dd&gt;&lt;asp:Literal runat="server" ID="list" /&gt;&lt;/dd&gt; </code></pre> <p>TooLPartTest.ascx.cs:</p> <pre><code>[WebBrowsable(true), Personalizable(true)] public string ListName { get; set; } protected override void OnInit(EventArgs e) { base.OnInit(e); InitializeControl(); } protected void Page_Load(object sender, EventArgs e) { } protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); list.Text = ListName ?? "(None)"; } public override EditorPartCollection CreateEditorParts() { return new EditorPartCollection(base.CreateEditorParts(), new[] { new CustomEditorPart { ID = ID + "_editorPart" } } ); } </code></pre> <p>ToolPart.cs</p> <pre><code>public class CustomEditorPart : EditorPart { private DropDownList _list; protected override void OnInit(EventArgs e) { base.OnInit(e); _list = new DropDownList(); _list.AppendDataBoundItems = true; _list.Items.Add(""); _list.DataTextField = "Title"; _list.DataValueField = "Title"; _list.DataSource = SPContext.Current.Site.RootWeb.Lists; _list.DataBind(); Controls.Add(new LiteralControl("List: ")); Controls.Add(_list); } public override bool ApplyChanges() { EnsureChildControls(); if (!string.IsNullOrEmpty(_list.SelectedValue)) ((ToolPartTest)WebPartToEdit).ListName = _list.SelectedValue; return true; } public override void SyncChanges() { EnsureChildControls(); var webpart = ((ToolPartTest)WebPartToEdit); _list.SelectedValue = webpart.ListName; } } </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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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