在发表时,提交按钮的事件里是这样的:
string cont = Server.HtmlEncode(tbContent.Text.ToString().Replace("'", "!"));-------------cont是发表的内容;
在显示位置绑定时是这样的:
<asp:Label ID="Label4" runat="server" Text='<%# Server.HtmlDecode(Eval("content").ToString()) %>'></asp:Label>
但是,在发表时,明明是有换行的,到了显示的地方却都在一行了!这是怎么回事啊?
拜托各位了!!
string cont = Server.HtmlEncode(tbContent.Text.ToString().Replace("'", "!"));-------------cont是发表的内容;
在显示位置绑定时是这样的:
<asp:Label ID="Label4" runat="server" Text='<%# Server.HtmlDecode(Eval("content").ToString()) %>'></asp:Label>
但是,在发表时,明明是有换行的,到了显示的地方却都在一行了!这是怎么回事啊?
拜托各位了!!
{
if(inputVal != null)
{
inputVal = inputVal.Replace(">",">");
inputVal = inputVal.Replace("<","<");
inputVal = inputVal.Replace("\'","'");
inputVal = inputVal.Replace("\"",""");
inputVal = inputVal.Replace(string.Format("{0}",(char)32), " ");
inputVal = inputVal.Replace(string.Format("{0}",(char)9)," ");
inputVal = inputVal.Replace(string.Format("{0}",(char)34),""");
inputVal = inputVal.Replace(string.Format("{0}",(char)39),"'");
inputVal = inputVal.Replace(string.Format("{0}",(char)13),"");
inputVal = inputVal.Replace(string.Format("{0}",(char)10)+string.Format("{0}",(char)13),"</p><p> ");
inputVal = inputVal.Replace(string.Format("{0}",(char)10), "<br/> ");
}
return inputVal;
}
把字符用以上函数进行Html编码就可以了。
----------------
问题解决!
再次感谢!马上给分!分少别介意,但是我的全部,仅表心意!