Add line breaks to Literal controls

2019-06-21 02:58发布

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/>

1条回答
女痞
2楼-- · 2019-06-21 03:18

Set it's Mode to PassThrough:

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

PassThrough The contents of the control are not modified.

查看更多
登录 后发表回答