日期:2014-05-20  浏览次数:20531 次

新手问题!多行文本输入的问题???高手请进………………¥¥¥¥
现在想在多行文本框中这么输入:
1、文字信息
2、文字信息
3、文字信息
但是我把这些信息输入到数据库时确只有“1、文字信息”其余两条信息没有,怎么回事?我是这样写的:this.txtContent.text
如果要在网页中同上面输入方式一样显示,该怎么写?就好像我现在在提问一样,马上问题显示方式同我刚才输入方式一样!
请高手给出这其中两步(输入数据库和从数据库中取出)

------解决方案--------------------
/// <summary>
/// 读,替换后放入数据库用 html代码取得 <textarea> 表单的值
/// </summary>
/// <param name= "StringValue "> </param>
/// <returns> </returns>
public static string GetHtmlEncode(string StringValue)
{
string str= " ";
str=HttpContext.Current.Server.HtmlEncode(StringValue);
str = str.Replace( "& ", "&amp; ");
str = str.Replace( " ' ", " ' ' ");
str = str.Replace( "\ " ", "&quot; ");
str = str.Replace( " ", "&nbsp; ");
str = str.Replace( " < ", "&lt; ");
str = str.Replace( "> ", "&gt; ");
str = str.Replace( "\n ", " <br> ");
return str;
}
/// <summary>
///写,修改时显示在文本框,进行转换 读取值到 <textarea> 表单里
/// </summary>
/// <param name= "StringValue "> </param>
/// <returns> </returns>
public static string ReadHtmlEncode(string StringValue)
{
string str=StringValue;
str = str.Replace( " <br> ", "\n ");
str = str.Replace( "&gt; ", "> ");
str = str.Replace( "&lt; ", " < ");
str = str.Replace( "&nbsp; ", " ");
str = str.Replace( "&quot; ", "\ " ");
return str;
}
------解决方案--------------------
自己寫替換函數也可以呀

Public Shared Function HTMLEncode(ByVal fString As System.Object) As String
If Not IsDBNull(fString) Then
fString = Replace(fString, "> ", "&gt; ")
fString = Replace(fString, " < ", "&lt; ")
fString = Replace(fString, " ' ", " ' ' ")
fString = Replace(fString, " ", "&nbsp; ")
fString = Replace(fString, Chr(13), " ")
fString = Replace(fString, Chr(10), " <BR> ")
Return fString
Else
Return " "
End If
End Function

Public Shared Function Htmldecode(ByVal fString As System.Object) As String
If Not IsDBNull(fString) Then
fString = Replace(fString, "&gt; ", "> ")
fString = Replace(fString, "&lt; ", " < ")
fString = Replace(fString, "&nbsp; ", " ")
fString = Replace(fString, " <BR> ", Chr(10))
Return fString
Else
Return " "
End If
End Function