我想更改我用 C# 开发的 SharePoint Web 部件中 HtmlTextArea 的一些属性。 HtmlTextArea 被用作我正在提取的某些 Sql Server 2005 数据的自定义显示,我想更改字体、颜色等,并使其成为只读的。我看到有一些方法,例如 HtmlTextArea.Attributes.Add、HtmlTextArea.Attributes.AddAttributes 和 HtmlTextArea.Attributes.CssStyle,但我不确定这些方法是否适合使用,也不确定如何使用它们.我知道使用 ASP.NET TextArea 控件我可以简单地使用内联 CSS,所以我试图找出一种在 C# 中设置内联 CSS 的方法。
另外,我想找到一种在控件之间添加换行符的方法,只是为了帮助放置。我已经在 CreateChildControls 中布置了所有控件,但我不知道如何控制它们的位置。例如,我有这样的东西:
protected override void CreateChildControls() { customers = new DropDownList(); customers.ID = "customers"; Controls.Add(customers); machines = new DropDownList(); machines.ID = "machines"; Controls.Add(machines); specsOutput = new HtmlTextArea(); specsOutput.ID = "specsOutput"; Controls.Add(specsOutput); }
我希望 HtmlTextArea 显示在 ddls 下方。感谢大家的帮助。
最佳答案
要添加内联 css,请使用 Attributes.Add("style", "color: white; background-color: black");
等。
您可以添加 LiteralControls
来帮助自定义控件的布局。
customers = new DropDownList();
customers.ID = "customers";
Controls.Add(customers);
Controls.Add(new LiteralControl("<br />"));
关于c# - ASP.NET HtmlTextArea 属性和换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2180307/