如何设置HtmlEditorExtender的内容的服务器端 [英] How to set HtmlEditorExtender's content server-side

查看:198
本文介绍了如何设置HtmlEditorExtender的内容的服务器端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的AjaxControlToolkit的HtmlEditorExtender在我的ASP.NET 4.0 Web应用程序:

I'm using the AjaxControlToolkit's HtmlEditorExtender in my ASP.NET 4.0 web app:

<asp:TextBox ID="myTxt" runat="server" TextMode="MultiLine" Height="80px" Width="100%" />
<act:HtmlEditorExtender ID="heMyTxt" runat="server" TargetControlID="myTxt">
  <Toolbar>
    etc...
  </Toolbar>
</act:HtmlEditorExtender>

当我设置文本​​框服务器端的内容是这样的:

When I set the content of the text box server-side like this:

myTxt.Text = htmlStringFromDatabase;

...文本框中的内容是文本HTML标记(即&LT; B&GT;大胆&LT; / B&GT; 显示出来就是这样,不喜欢的粗体)。该格式不会转让,但扩展器做文本框的工作,并设置其工具栏和按钮等是否有不同的方式来设置的内容?

...the content in the textbox is the literal HTML markup (i.e. <b>Bold</b> shows up just like that, not like Bold). The formatting doesn't transfer, but the Extender does do its work on the textbox and set up its toolbar and buttons, etc. Is there a different way to set the content?

编辑:原来,HTML我走出 myTxt (即扩展器连接到控制)EN codeD HTML。所以,现在的问题是如何阻止编码其内容的控制权。这个问题也presented在<一href=\"http://stackoverflow.com/questions/10825791/how-do-i-stop-htmleditorextender-encoding-html-in-postback\">this问题,但我没有使用 LoadControl()或设计师到我的网页;我手写我的标记。

turns out the HTML I get out of myTxt (the control that the extender is attached to) is encoded HTML. So now the question is how to stop the control from encoding its content. This problem is also presented in this question, but I'm not using LoadControl() or the designer to my page; I've written my markup manually.

另外,我不知道这是否有差别,但我拉出来的文字在页面的的Page_Load 处理TextBox的。

Also, I don't know if this makes a difference, but I'm pulling the text out of the TextBox in the page's Page_Load handler.

推荐答案

尝试做这样的,

myTxt.Text = HttpUtility.HtmlDecode(htmlStringFromDatabase);

这篇关于如何设置HtmlEditorExtender的内容的服务器端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆