写个方法转换一下:/// <summary>
/// 替换html中的特殊字符
/// </summary>
/// <param name="theString">需要进行替换的文本。</param>
/// <returns>替换完的文本。</returns>
public string HtmlEncode(string theString)
{
theString=theString.Replace(">", ">");
theString=theString.Replace("<", "<");
theString=theString.Replace(" ", " ");
theString=theString.Replace(" ", " ");
theString=theString.Replace("\"", """);
theString=theString.Replace("\'", "'");
theString=theString.Replace("\n", "<br/> ");
return theString;
} /// <summary>
/// 恢复html中的特殊字符
/// </summary>
/// <param name="theString">需要恢复的文本。</param>
/// <returns>恢复好的文本。</returns>
public string HtmlDiscode(string theString)
{
theString=theString.Replace(">", ">");
theString=theString.Replace("<", "<");
theString=theString.Replace(" "," ");
theString=theString.Replace(" "," ");
theString=theString.Replace(""","\"");
theString=theString.Replace("'","\'");
theString=theString.Replace("<br/> ","\n");
return theString;
}不知道能帮你么?
/// 替换html中的特殊字符
/// </summary>
/// <param name="theString">需要进行替换的文本。</param>
/// <returns>替换完的文本。</returns>
public string HtmlEncode(string theString)
{
theString=theString.Replace(">", ">");
theString=theString.Replace("<", "<");
theString=theString.Replace(" ", " ");
theString=theString.Replace(" ", " ");
theString=theString.Replace("\"", """);
theString=theString.Replace("\'", "'");
theString=theString.Replace("\n", "<br/> ");
return theString;
} /// <summary>
/// 恢复html中的特殊字符
/// </summary>
/// <param name="theString">需要恢复的文本。</param>
/// <returns>恢复好的文本。</returns>
public string HtmlDiscode(string theString)
{
theString=theString.Replace(">", ">");
theString=theString.Replace("<", "<");
theString=theString.Replace(" "," ");
theString=theString.Replace(" "," ");
theString=theString.Replace(""","\"");
theString=theString.Replace("'","\'");
theString=theString.Replace("<br/> ","\n");
return theString;
}不知道能帮你么?
解决方案 »
- 100分找兄弟们解决个问题,如果触发事件后等待10秒???
- 谁搞过这样SQL数据库复制(比如数据库事务复制,快照复制等),我想在两台服务器之间实现数据同步,但是无法实现,报错说总是连接不上Subcr 另一台服务器,谁搞过请赐教,或者贴个图(步骤方案)出来,谢谢啊
- 请问个ASPX读取本地设备的问题,或说视本地DLL引用的问题
- 框架内一个页面调用另一个页面的方法?
- 请急救treeview中的数据绑定问题!
- 初学,帮我看看下面的代码有哪些问题?
- 太简单啦,进来吧!
- 开发进销存软件,web好还是winfrom窗体好啊
- 在.NET中一般怎么设计类呀?
- 请问要学习asp.net需要有什么基础?
- image 对象如何转换成 HttpPostedFile 呢
- 如果将某个类的一般属性和List属性分别绑定到不同的Repeater
我用freetextbox就没转换过啊。
我开始也认为是要转换呢。但后来发现不需要。
你这样输出的原因可能是浏览器没有解释执行,你看看为什么浏览器为什么没有解释执行的原因吧。
With e.Row
.Cells(4).Text = .Cells(4).Text.Replace("<", "<")
.Cells(4).Text = .Cells(4).Text.Replace(">", ">")
End With
不知道是否能帮你解决问题。
<div>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Contents") %>'></asp:TextBox> <br />
<ftb:freetextbox id="FreeTextBox1" runat="server" Width="600px" ToolbarLayout="ParagraphMenu,FontFacesMenu,FontSizesMenu,FontForeColorsMenu|Bold,Italic,
Underline,Strikethrough;Superscript,Subscript,RemoveFormat|JustifyLeft,JustifyRight,
JustifyCenter,JustifyFull;BulletedList,NumberedList,Indent,Outdent;CreateLink,Unlink,
InsertImageFromGallery,InsertRule|Cut,Copy,Paste;Undo,Redo,Print,Preview" ButtonSet="Office2003" Language="zh-CN" StripAllScripting="True"></ftb:freetextbox>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
</form> SqlConnection cn;
String strConnection = ConfigurationSettings.AppSettings["ConnectionString"];
cn = new SqlConnection(strConnection);
SqlCommand cm = new SqlCommand("freeproc", cn);
cm.CommandType = CommandType.StoredProcedure; cm.Parameters.Add(new SqlParameter("@utitle", SqlDbType.VarChar, 50));
cm.Parameters.Add(new SqlParameter("@unews", SqlDbType.NVarChar,250));
cm.Parameters["@utitle"].Value = TextBox1.Text;
cm.Parameters["@unews"].Value = FreeTextBox1.Text;
cm.Connection.Open();
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!Page.IsPostBack)
{
newsid = Request.Params["InfoId"];
SqlConnection myConnection = new SqlConnection(DB.strConn);
SqlDataAdapter myCommand = new SqlDataAdapter("SELECT * FROM Inform WHERE InfoId="+newsid, myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "notice");
dr = ds.Tables["notice"].Rows[0];
title.Text=dr["Infotitle"].ToString();
title.Font.Name="宋体";
this.date.Text=dr["Infodate"].ToString();
string strcontent=dr["Infocontent"].ToString();
string str=Server.HtmlDecode(strcontent); //关键是这,实现转换
this.content.Text=str; }
}
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
SortExpression="ID" />
<asp:BoundField DataField="title" HeaderText="title" SortExpression="title" />
<asp:BoundField DataField="news" HeaderText="news" SortExpression="news" />
<asp:BoundField DataField="date" HeaderText="date" SortExpression="date" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:emapgoConnectionString6 %>"
SelectCommand="SELECT [ID], [title], [news], [date] FROM [free] ORDER BY [ID]"></asp:SqlDataSource>
</div>
</form>
function ClearWord()
{
var text = FTB_API['FreeTextBox1'].GetHtml();text=text.replace(/<FONT[^>]*>/gi,"");
text=text.replace(/<\/FONT>/gi,"");
text=text.replace(/<U>/gi,"");
text=text.replace(/<\/U>/gi,"");
text=text.replace(/<H[^>]*>/gi,"");
text=text.replace(/<\/H[^>]*>/gi,"");// Change these tags.
text=text.replace(/<B[^>]*>/gi,"&bold");
text=text.replace(/<\/B[^>]*>/gi,"&cbold");
text=text.replace(/<STRONG[^>]*>/gi,"&bold");
text=text.replace(/<\/STRONG[^>]*>/gi,"&cbold");text=text.replace(/<I[^>]*>/gi,"&ital");
text=text.replace(/<\/I[^>]*>/gi,"&cital");
text=text.replace(/<EM[^>]*>/gi,"&ital");
text=text.replace(/<\/EM[^>]*>/gi,"&cital");text=text.replace(/<UL[^>]*>/gi,"&ultag");
text=text.replace(/<LI[^>]*>/gi,"&litag");
text=text.replace(/<OL[^>]*>/gi,"&oltag");
text=text.replace(/<\/OL>/gi,"&olctag");
text=text.replace(/<\/LI>/gi,"&lictag");
text=text.replace(/<\/UL>/gi,"&ulctag");text=text.replace(/<P[^>]*>/gi,"¶g");
text=text.replace(/<\/P>/gi,"");/*
text=text.replace(/?gi,'\"');
text=text.replace(/?gi,'\"');
text=text.replace(/?gi,'\"');
text=text.replace(/mailto:/gi,'\"');
text=text.replace(/?g,"Ä");
text=text.replace(/?g,"Ö");
text=text.replace(/?g,"Ü");
text=text.replace(/?g,"ä");
text=text.replace(/?g,"ö");
text=text.replace(/?g,"ü");
text=text.replace(/?gi,"ß");
*/text=text.replace(/<[^>]>*;/gi,"");
text=text.replace(/<\/[^>]>*;/gi," ");
text=text.replace(/<o:[^>]*>/gi,"");
text=text.replace(/<\/o:[^>]*>/gi,"");
text=text.replace(/<\?xml:[^>]*>/gi,"");
text=text.replace(/<\/?st[^>]*>/gi,"");
text=text.replace(/<[^>]*</gi,"<");
text=text.replace(/<SPAN[^>]*>/gi,"");
text=text.replace(/<SPAN[^class]*>/gi,"");
text=text.replace(/<\/SPAN>/gi,"");
//text=text.replace(/<\/A>/gi,"");// Clear the inner parts of other tags.//text=text.replace(/style=[^>]*"/g,' ');
//text=text.replace(/style=[^>]*'/g," ");
text=text.replace(/style=[^>]*>/g,">");
text=text.replace(/lang=[^>]*>/g,">");
text=text.replace(/name=[^>]* /g,"");
text=text.replace(/name=[^>]*>/g,">");
text=text.replace(/<A[^>]*>/g,"");//text=text.replace(/<p[^>]*>/gi,"<p>");
// Put the tags back
text=text.replace(/&bold/g,"");
text=text.replace(/&cbold/g,"");text=text.replace(/&ital/g,"<EM>");
text=text.replace(/&cital/g,"</EM>");text=text.replace(/&ultag/g,"<UL>");
text=text.replace(/&litag/g,"<LI>");
text=text.replace(/&oltag/g,"<OL>");
text=text.replace(/&olctag/g,"<\/OL>");
text=text.replace(/&lictag/g,"<\/LI>");
text=text.replace(/&ulctag/g,"<\/UL>");text=text.replace(/¶g/g,"<BR>");
FTB_API['FreeTextBox1'].SetHtml(text);
//document.Form1.FreeTextBox1.innerHTML = text;
}