English 中文(简体)
显示贴有线段的显示器
原标题:Displaying posted text with line breaks

On aspx page I have asp:textbox multilined, where I type data. When I assign TextBox1.text to a string i get something like this:

"line1
line2
line3"

但是,如果我试图把它重新打上字面,我会:

line1 line2 line3

(无线虫)

How to solve it? Is the only way to replace the with <br />?

A note: If I store the in put in database (sqlserver), and open the table in sql management studio -> edit rows-> I see string line1line2line3 (all together), but if try to copy to clipboard this content (Ctrl+C) only line1 is copied! Why?
Also, If i bind this data to a repeater, and Eval("myfield") to repeater I get the line brake!

问题回答

C部分

string htmlFormattetText = textStringFromDB.Replace("
","<br />")

SELECT REPLACE(TextCol, 
 , <br />  FROM MyTable

这里trick。 你的意见也一样:

页: 1

但是,你们的产出也一样:

我试图把它 literal倒在字面上。

字面控制只是使原始的html,而raw html”忽视了断线<>。 多线文本箱作为“html”编码“文本领域/编码”要素,文本领域各行距的价值。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!