This is a migrated thread and some comments may be shown as answers.
Question about binding editor value
1 Answer 113 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chris
Top achievements
Rank 1
Chris asked on 10 Dec 2010, 10:33 AM
Hi,
I am using telerik editor to create rich text property of my model. I create a model and it saves into DB successfully. But when I try to rebind the text in Edit view, I found it always render text with html tags other than compiled rich text.
Below is the value when debugging, which is simply saved from editor's model binding in Create view:
<p>test<strong> body,</strong>a new <span style="text-decoration:underline;"><em>text</em></span></p>

And I used three ways to bind this property:
<%= Html.Telerik().EditorFor(model => model.Body))%>
<%= Html.Telerik().Editor().Name("Body").Value(Model.Body)%>
<%= Html.Telerik().Editor().Name("Body").Value(HttpUtility.HtmlDecode(Model.Body))%>
They all render:
<p>test<strong> body,</strong>a new <span style="text-decoration:underline;"><em>text</em></span></p>
in the editor.

Anyone knows where am I wrong? Thanks a lot

1 Answer, 1 is accepted

Sort by
0
Manoj Sharma*
Top achievements
Rank 1
answered on 14 Dec 2010, 06:43 PM
Same issue here
using MVC 3 RC1 ,  MVC Q3 2010, Razor Engine C#

I am binding model to Editor, it save fine but when it reloads the same data in the same editor view it shows HTML instead,  using
@Html.Telerik().EditorFor(model => model.myProperty)

seems like client to server is encoded twice but return journey decodes only once


not ideal but temp workround (for an internal app)
@Html.Telerik().EditorFor(model => model.LettingPremises).Encode(false)
 +
[ValidateInput(false)] for controller to turn off request validation!


looking for better fix or suggestions?

Tags
Editor
Asked by
Chris
Top achievements
Rank 1
Answers by
Manoj Sharma*
Top achievements
Rank 1
Share this question
or