c# - ASP.NET HtmlTextArea 属性和换行符

标签 c# asp.net css sharepoint newline

我想更改我用 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/

相关文章:

c# - gridview 中的日期格式仅包含日期

html - 文本后面的粗下划线

C# 正则表达式分割字符串并在分割中包含匹配的表达式

C# 字符串操作

c# - Sys.WebForms.PageRequestManagerParserErrorException : The message received from the server could not be parsed

html - 使用 flexbox 的级联网格布局

php - 使用 bootstrap 创建横跨屏幕宽度的行

c# - 如何加载ascx文件中的资源 key ?

c# - 应用程序在 Visual Studio 之外卡住。从 Visual Studio 启动它时它工作

asp.net - 动画 ListView 页面更改