C# 制作标签多行

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16662369/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-10 01:36:32  来源:igfitidea点击:

Make label multiline

c#asp.net

提问by Jake

I know the easy solution would be to make the label a textbox with multiline but this does not solve the problem since I want to render anchor tags inside the text value. For example:

我知道简单的解决方案是将标签设为多行文本框,但这并不能解决问题,因为我想在文本值内呈现锚标记。例如:

 <asp:Label ID='myLabel' runat="server" Text=" This is my label etc... go 
here  <a href='Destn.aspx'>Here</a> to update" />

This can't be done by using a textbox since a textbox will not display the anchor tag as a link instead it will display as plain text

这不能通过使用文本框来完成,因为文本框不会将锚标记显示为链接,而是显示为纯文本

采纳答案by shreyash gajbhiye

<asp:Label 
    ID='myLabel' 
    runat="server"  
    style="word-wrap:break-word;" 
    Width="140px" 
    Text=" This is my label etc... go here <a href='Destn.aspx'>Here</a> to update" />

Add width property and provide any appropriate value whatever you want and add one css style which will wrap the word

添加 width 属性并提供任何您想要的任何适当值,并添加一个将环绕单词的 css 样式

回答by Habib

Use <br/>in your TEXT to create new row in label text.

<br/>在您的文本中使用以在标签文本中创建新行。

<asp:Label ID='myLabel' 
       runat="server" 
       Text=" This is my label etc... go <br /> here  
       <a href='Destn.aspx'>Here</a> to update" />

See: <br>- MDN

请参阅:<br>- MDN

The HTML <br>Element (or HTML Line Break Element) produces a line break in text (carriage-return).

HTML<br>元素(或 HTML 换行元素)在文本中产生换行符(回车)。

回答by Pankaj Agarwal

Select the dropdown next to the label. Then Press Ctrl + Enter key for Line - break

选择标签旁边的下拉菜单。然后按 Ctrl + Enter 键换行 - 换行

Edit

编辑

It work only when page open in Design Mode

仅在设计模式下打开页面时才有效