如何在详细信息视图中进行html解码?

b0x*_*0rz 1 c# tinymce html-encode detailsview

<asp:DetailsView ID="DetailsView1" runat="server"
DataSourceID="SqlDataSource1" AutoGenerateRows="False"
DataKeyNames="ID" DefaultMode="Insert" >
Run Code Online (Sandbox Code Playgroud)

...

<asp:TextBox ID="ShortExcerptTextBox" runat="server"
Text='<%#Bind("ShortExcerpt") %>' class="mceEditor"
TextMode="MultiLine"></asp:TextBox>
Run Code Online (Sandbox Code Playgroud)

这是我的代码.

问题是我需要以某种方式以某种方式HttpUtility.HtmlDecode在那里#Bind("ShortExcerpt"),但不知道如何.

最初的问题是tinyMCE(富文本编辑器)本身对文本进行编码,但在读取时不对其进行解码.长话:P

所以,请,有人,解释,如何HttpUtility.HtmlDecode阅读的文本,#Bind("ShortExcerpt")请?

日Thnx

Tim*_*ter 5

我不认为你可以用HtmlDecodeBind.

所以要么尝试HtmlDecode使用codebehind中的TextBox:

<asp:TextBox ID="ShortExcerptTextBox" runat="server"
    Text='<%# Eval("ShortExcerpt") %>' 
    OnDataBinding="ShortExcerptTextBox_DataBinding" class="mceEditor"
    TextMode="MultiLine">
</asp:TextBox>


protected void ShortExcerptTextBox_DataBinding(object sender, EventArgs e)
{
    var txt = (TextBox)sender;
    txt.Text = HttpUtility.HtmlDecode(txt.Text);
}
Run Code Online (Sandbox Code Playgroud)

或尝试使用Eval(如果可以接受):

<asp:TextBox ID="ShortExcerptTextBox" runat="server"
    Text='<%# HttpContext.Current.Server.HtmlDecode((string)Eval("ShortExcerpt")) %>' 
    class="mceEditor"
    TextMode="MultiLine">
</asp:TextBox>
Run Code Online (Sandbox Code Playgroud)

两者都没有测试过.