<textarea rows="2" name="S1" cols="20"><%=rs("content")%></textarea>
方法一:
<textarea cols="80" rows="14" width="100%" height="100%" name="content"></textarea>
没有wrap="off"的话,就会自动换行了。
方法二:
<SCRIPT>
function ChangeWrap(oSelect, oTA)
{
cValue = oSelect.options(oSelect.selectedIndex).value;
oTA.wrap = cValue;
}
</SCRIPT>
...
<SELECT ID=cboWrap οnchange="ChangeWrap(this, txt1)">
<OPTION VALUE=soft>自动换行
<OPTION VALUE=hard>硬换行
<OPTION VALUE=off>不换行
</SELECT>
<P>
<TEXTAREA ID=txt1 STYLE="height:200;width:200"></TEXTAREA>
<
textarea
id
=
"txtContent"
rows
=
"2"
name
=
"S1"
cols
=
"20"
></
textarea
>
<
script
>
//用js来赋值
var str='<%=replace(replace(rs("content"),"<
BR
>","\n"),"'","\'")%>';//注意<
br
>替换为\n,'替换为\',要不你的rs("content")有'时变量的值不闭合就会出错
document.getElementById("txtContent").value=str;
</
script
>
Replace(Server.HTMLEncode(rs("content")),vbCrLf,"<br>")
public String dohtm(String str) {
str=str.replace("&","&");
str=str.replace("<","<");
str=str.replace(">",">");
str=str.replace(" "," ");
str=str.replace("\n","<br>");
return str;
}
private string HtmlTransLate(string strHtmlCode) {
string strReturnHtml = System.Web.HttpContext.Current.Server.HtmlEncode(strHtmlCode);
strReturnHtml = strReturnHtml.Replace("\r\n", "<br/>");
return strReturnHtml;
}
this.label.text=HtmlTransLate(字符串);
最终的结果是在输出的结果上带\n最好用,最简单