Reputation: 10981
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;
...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?
EDIT: 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.
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.
Upvotes: 3
Views: 2416
Reputation: 452
I was able to solve this problem like this :
Literal lit = new Literal();
lit.Mode = LiteralMode.PassThrough;
lit.Text = HttpUtility.HtmlDecode(HTMLTExt);
TextBox1.Text = lit.Text; // The text box which HTMLEditorExtender is attached to
Upvotes: 0
Reputation:
Try to do like this,
myTxt.Text = HttpUtility.HtmlDecode(htmlStringFromDatabase);
Upvotes: 2