如何在标签中显示带有空格的文本 [英] how to show text with whitespace in label

查看:181
本文介绍了如何在标签中显示带有空格的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在从数据库中获取文本以使其工作正常,但是它没有在文本之间显示大量空白...?如何显示与数据库中相同的文本...


i am fetching text from database into label its working fine, but it is not showing the lots of white space between the text...?how it is possible to show text same as it is in databse...

推荐答案

将数据发送到Web浏览器时,它将空格字符串压缩为单个空格-不管数据源如何.为了解决这个问题,请将您的空格转换为& nbsp;"总是显示为单个空格字符,并且不会被压缩为单个空格.
在设置label.Text值之前,可以在字符串上使用string.Replace(",& nbsp;").
[edit] Arrgggh!浏览器吞下了&"号分号,并用空格替换了! -OriginalGriff [/edit]
When you send data to a web browser, it squashes strings of spaces to a single space - regardless of the data source. To get round this, convert your spaces to " " which are always shown as a single space character and do not get squashed into a single spaces.
You could use string.Replace(" ", " ") on your string before you set the label.Text value.

[edit]Arrgggh! Browser swallowed the ampersand nbsp semicolon and replaced it with space! - OriginalGriff[/edit]


要在HTML页面中显示空格,可以使用 实体.

只需用 实体替换空格.

有关HTML实体的更多信息,您可以查看以下链接: http://www.w3schools.com/html/html_entities.asp [ ^ ].

For more information about HTML entities, you can see that link: http://www.w3schools.com/html/html_entities.asp[^].


您好尝试此代码


< asp:label style =字母间距:3像素;" id ="Label1" runat ="server"/>
Hello try this code


<asp:label style="letter-spacing: 3px;" id="Label1" runat="server" />


这篇关于如何在标签中显示带有空格的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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