datalist格式换行符 [英] datalist format line break

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

问题描述

asp.net 3.5 c#mssql 2005 express ---

我创建了一个"插入" formview中的多行文本框,用户可以在其中输入几行文本到MSSql数据库。然后,该文本作为datalist段出现在许多页面上。

巧合的是,我正用这个文本框来填充论坛问题。

我的问题是数据主义者忽略了在段落之间插入空格的carraige返回。现在,我正在插入< br /> < br>完成任务但如果它的行为像这个文本框那样点击"输入"会更好。钥匙产生差距......

...这样的。

我很感激任何建议或资源,我可以从中学到答案。一如既往,非常感谢。
asp.net 3.5 c# mssql 2005 express---

I've created an "insert" multiline textbox in formview in which the user can enter several lines of text that goes to a MSSql database. The text then appears on a number of page as a datalist paragraph.

Coincidently , exactly this text box I'm using to imput the forum question.

My issue is that the datalist ignores the carraige return that inserts a space between the paragraphs. For now, I'm inserting <br /> <br > to accomplish the task but it would be better if it would behave like this text box where hitting the "enter" key produces a gap...

...like this.

I'd appreciate any suggestions or a resource where I can learn the answer. As always, thanks very much.

推荐答案

简单以及PHP具有nl2br功能的原因。存储新的行字符,因为这是存储数据的正确方法,并创建一个将新行字符转换为br标记的功能,这是显示目的所必需的。

我找到了这两种方法它:a a = a.Replace("\\\\ n","< br />"");
或a = a.Replace(Environment.NewLineCharacter," br />")

只要确保以纯粹的形式存储文本为了显示目的清洁它。
Simple and the reason why PHP has a nl2br function.  Store the new line characters as this is the proper way to store the data and create a function that converts new line characters to br tags where this is required for display purposes.

I found these two ways to do it:
a = a.Replace("\r\n", "<br />");
or
a = a.Replace(Environment.NewLineCharacter, "<br />")

Just make sure you store the text in a pure form and clean it for display purposes.


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

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