我正在为 Sharepoint 2010 开发 WebPart。我创建了自定义属性,但我想更改布局。我希望下面的元素看起来像默认元素(间距和填充等)。
protected override void CreateChildControls()
{
PartPanel = new UpdatePanel();
PartPanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
label2 = new Label();
label2.Text = "Choose component <br/><br/>";
ddl = new DropDownList();
ddl.ID = "ddl";
ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);
ddl.EnableViewState = false;
ddl.AutoPostBack = true;
ddl.Items.Insert(0 ,"--Select--");
ddl.Items.Insert(1, "a");
ddl.Items.Insert(2, "b");
label1 = new Label();
label1.Text = "";
channels = new DropDownList();
channels.ID = "a";
channels.Visible = false;
channels.DataSource = Enumerable.Range(1, 15);
channels.DataBind();
videos = new TextBox();
videos.Visible = false;
PartPanel.ContentTemplateContainer.Controls.Add(label2);
PartPanel.ContentTemplateContainer.Controls.Add(ddl);
PartPanel.ContentTemplateContainer.Controls.Add(label1);
PartPanel.ContentTemplateContainer.Controls.Add(videos);
PartPanel.ContentTemplateContainer.Controls.Add(channels);
this.Controls.Add(PartPanel);
base.CreateChildControls();
}
在这里做什么?正如您所注意到的,我添加了一些换行符,但这并没有达到我想要的效果。