在ASP.NET中设置标签的文本方向 [英] Setting the text direction for a Label in ASP.NET
问题描述
我正在开发一种多语言应用程序,它要求我根据用户语言动态更改文本方向(ltr或rtl).
I'm working on a multi-lingual application which requires me to change the text direction (either ltr or rtl) dynamically according to the user language.
我为此使用了标签.我给它分配了一个css类,它可以设置方向,但是不起作用.
I used a label for this. I assigned it a css class which would set the direction but its not working.
我还在其CssStyleCollection列表中添加了一种样式,但它也无法正常工作.
I also added a style to its CssStyleCollection list but its not working too.
我在哪里做错了?可以通过什么方式实现它?
Where am I doing it wrong? What are the ways in which it can be achieved?
推荐答案
如果发布正在使用的CSS,则我可能会发现任何可能出错的地方.否则,请在标签控件中尝试以下操作:
If you post the CSS you're using, I may be able to identify anything that could be wrong with it. Otherwise, try this in your label control:
Label myLabel = new Label();
myLabel.Attributes.Add("dir", "rtl");
当然,您可能希望在顶级标签(例如<body />
)上设置方向,以便它影响整个页面,而不仅仅是一个标签.
Of course, you may want to set the direction at a top-level tag such as the <body />
so it affects the entire page and not just one label.
这篇关于在ASP.NET中设置标签的文本方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!