如何将CSS类分配给HtmlTextArea元素? [英] How can I assign a CSS Class to HtmlTextArea elements?

查看:92
本文介绍了如何将CSS类分配给HtmlTextArea元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用C#创建的其他元素,我可以使用这种类型的代码:



With other elements created in C#, I can use either this type of code:

txtarAccountCodes = new HtmlTextArea
{
    CssClass = "clearonreset"
};





...或者这个:





...or this:

txtarAccountCodes.CssClass = "clearonreset";





...将CSS类分配给元素,但HtmlTextArea元素不允许使用。有没有办法将CSS类分配给服务器端的HtmlTextArea元素?



...to assign a CSS Class to an element, but neither is allowed with HtmlTextArea elements. Is there a way to assign a CSS class to HtmlTextArea elements server-side?

推荐答案

设置 HtmlTextArea的CSS类控制,或 System.Web.UI.HtmlControls 命名空间中定义的任何其他内容,你必须使用 属性集合 [ ^ ]:

To set the CSS class of an HtmlTextArea control, or anything else defined in the System.Web.UI.HtmlControls namespace, you'll have to use the Attributes collection[^]:
txtarAccountCodes.Attributes["class"] = "clearonreset";



或者,您可以使用 TextMode TextBox 控件c $ c>设置为 MultiLine


Alternatively, you could use the TextBox control with the TextMode set to MultiLine:

txtarAccountCodes = new TextBox
{
    TextMode = TextBoxMode.MultiLine,
    CssClass = "clearonreset"
};


请参阅: https://msdn.microsoft.com /en-us/library/system.web.ui.htmlcontrols.htmlcontrol.style%28v=vs.110%29.aspx [ ^ ]。



-SA


这篇关于如何将CSS类分配给HtmlTextArea元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆