2014-10-21 3 views
0

나는 ASP.NET 응용 프로그램에서 일하고 있습니다. 텍스트는 줄 바꿈이 '\r\n'으로 저장되어있는 데이터베이스에서 가져온 것이며 MultiLine이 설정된 TextBox에 텍스트를 넣을 것입니다. <br/>, &#13;&#10;, &#10;을하지만, 값은 단지 texbox에 인쇄되어 있습니다 : 그러나, 나는 내가 가진 줄 바꿈을 대체하려고했습니다새 라인 텍스트 영역에서 C#

string description = description.Replace("\\r\\n", "<br/>"); 
lblDescriptionV.Text = description; 

텍스트 상자에 줄 바꿈을 얻을 수없는 것. 그러면 읽을 수 있습니다 : "Line 1<br/>line 2".

+1

'Environment.NewLine' –

+0

이 답변을 확인할 수있는 것처럼 보입니다. http://stackoverflow.com/questions/5909864/multiline-textbox-multiple-newline –

답변

0
<asp:TextBox runat="server" ID="txtArea" TextMode="MultiLine" Rows="10" /> 

코드 뒤에로 교체 :

string description = "Hello\\r\\nThere\\r\\nFriend"; 
description = description.Replace("\\r\\n", "\n"); 

참고 :

protected void Page_Load(object sender, EventArgs e) 
{ 
    txtArea.Text = "Hello\nThere\nFriend"; 
} 

따라서 다음과 같은 요구 당신은 라벨에 휴식을 입력 할 수 없습니다 (lblDescriptionV를)

+0

감사합니다. 조금 이상한 내가 어떻게 보았는지는 '\ n'을 이것으로 대체했다. 하지만 지금 작동합니다 :) 추신. lblDescriptionV는 실제로 텍스트 영역입니다. 저의 이름 짓기 관습에 약간의 실수가 있습니다 ... – user1662292

0

Environment.NewLine

관련 문제