如何让我的 Sharepoint 子控件水平对齐?

How can I get my Sharepoint Child Controls to align horizontally?

我正在 Web 部件的重写 CreateChildControls() 方法中创建控件。

我的代码是这样的(没有双关语意):

this.Controls.Add(new LiteralControl("<h2>Duckbilled Platypus Unlimited</h2>"));
this.Controls.Add(new LiteralControl("<h3>Angle of Repose of Bill: "));
boxRequestDate = new TextBox();
this.Controls.Add(boxRequestDate);
this.Controls.Add(new LiteralControl("</h3>"));

this.Controls.Add(new LiteralControl("<h3>Venomosity/Lethality Quotient of Poison Toe: "));
boxPaymentAmount = new TextBox();
this.Controls.Add(boxPaymentAmount);
this.Controls.Add(new LiteralControl("</h3>"));

...我看到了这个:

我想看到的是 "Venomosity" LiteralControl 和 TextBox 在第一个 LiteralControl 和 TextBox 的右侧/水平对齐(在它们的右侧,而不是在它们的下方)。我怎样才能做到这一点?

尝试这样的事情:

this.Controls.Add(new LiteralControl("<h2>Duckibilled Platypus Unlimited</h2>"));
this.Controls.Add(new LiteralControl("<h3 style='display: inline-block; width: 400px;'>Angle of Repose of Bill: </h3>"));
boxRequestDate = new TextBox();
this.Controls.Add(boxRequestDate);

this.Controls.Add(new LiteralControl("<br />"));

this.Controls.Add(new LiteralControl("<h3 style='display: inline-block; width: 400px;'>Venomosity/Lethality Quotient of Poison Toe: </h3>"));
boxPaymentAmount = new TextBox();
this.Controls.Add(boxPaymentAmount);

请注意,您不能在 h3 标签中包含文本框(通过 HTML 规则)。此外,最好在 CSS 内部使用 class 而不是像这样的内联样式,但这种方式应该适合你。用 CSS 而不是“
”来处理 "break" 也会更好,但为了快速修复,这样做就可以了。