添加换行符文字控制 [英] Add line breaks to Literal controls

查看:136
本文介绍了添加换行符文字控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些问题与ASP.NET 文字控制,因为它不呈现< BR /> 标记。

code

 字符串strTemp = task.Description.ToString();
lit_description.Text = strTemp.Replace(\\ r \\ n,< BR />中);

输出:

  LG服务票证< BR />< BR /> < BR />< BR />  - 日期:< BR />< BR />  -  DATE OUT(如2011年2月11日):(例如:2011年2月11日。)< BR />< BR />  - 客户端有关键数据(附加费另行收取):其中; BR />< BR />  -  Windows密码:LT; BR />< BR />  - 附件:LT; BR />< BR />< BR />< BR />< BR />客户投诉:LT; BR />< BR />< BR />< BR />


解决方案

设置它的<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.literal.mode.aspx\"><$c$c>Mode直通

 &LT; ASP:文字标识=lit_description模式=直通&GT;&LT; / ASP:文字&GT;


  

直通控件的内容不会被修改。


I have some problems with the ASP.NET Literal control because it isn't rendering the <br/> tag.

code

string strTemp = task.Description.ToString();
lit_description.Text = strTemp.Replace("\r\n", "<br/>");

output:

LG SERVICE TICKET<br/><br/> <br/><br/>- DATE IN (eg. Feb 11, 2011):<br/><br/>- DATE OUT (eg. Feb 11, 2011):<br/><br/>- Client Has Critical Data (fees will apply):<br/><br/>- Windows Password: <br/><br/>- Accessories:<br/><br/><br/><br/><br/>Client Complaint:<br/><br/><br/><br/>

解决方案

Set it's Mode to PassThrough:

<asp:Literal Id="lit_description" Mode="PassThrough"></asp:Literal>

PassThrough The contents of the control are not modified.

这篇关于添加换行符文字控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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