在 VB.NET 标签中,
lblNotification.Text = send email to <name@gmail.com> me
O/P 我得到的是 send email to me
而且它不显示 <name@gmail.com>
.如何显示包括尖括号在内的全文。也就是说,我需要将 O/P 设为 send email to <name@gmail.com> me
.谢谢。
最佳答案
使用以下代码:
Protected Overrides Sub OnLoad(ByVal e As EventArgs)
MyBase.OnLoad(e)
Label1.Text = HttpUtility.HtmlEncode("send email to <name@gmail.com> me")
End Sub
HttpUtility.HtmlEncode方法会自动将您的字符串转换为 html 编码的文本
关于c# - 在标签中使用尖括号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14191406/