asp.net 怎么让文本框出现<br>而不是换行?急啊
4个回答
展开全部
给字符编码
给个例子你 看看
using System;
using System.IO;
using System.Web;
using System.Web.UI;
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
// This could mess up HTML.
string text = "you & me > them"; // 1
// Replace > with >
string htmlEncoded = Server.HtmlEncode(text); // 2
// Now has the > again.
string original = Server.HtmlDecode(htmlEncoded); // 3
// This is how you can access the Server in any class.
string alsoEncoded = HttpContext.Current.Server.HtmlEncode(text); // 4
StringWriter stringWriter = new StringWriter();
using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
{
// Write a DIV with encoded text.
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.WriteEncodedText(text);
writer.RenderEndTag();
}
string html = stringWriter.ToString(); // 5
}
}
给个例子你 看看
using System;
using System.IO;
using System.Web;
using System.Web.UI;
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
// This could mess up HTML.
string text = "you & me > them"; // 1
// Replace > with >
string htmlEncoded = Server.HtmlEncode(text); // 2
// Now has the > again.
string original = Server.HtmlDecode(htmlEncoded); // 3
// This is how you can access the Server in any class.
string alsoEncoded = HttpContext.Current.Server.HtmlEncode(text); // 4
StringWriter stringWriter = new StringWriter();
using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
{
// Write a DIV with encoded text.
writer.RenderBeginTag(HtmlTextWriterTag.Div);
writer.WriteEncodedText(text);
writer.RenderEndTag();
}
string html = stringWriter.ToString(); // 5
}
}
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
过滤字符
追问
怎么过滤啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
文本框架 要去前台改动 就能显示了 你那是后台
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询