This is a migrated thread and some comments may be shown as answers.

[Solved] problem in decoding value (bug?)

1 Answer 111 Views
Editor
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
mahmoud
Top achievements
Rank 1
mahmoud asked on 21 May 2011, 07:27 AM
I use the EditorFor(...) to bind the editor to my property. But the problem arises in loading when it doesnt decode the data to show it properly.
for example:
after loading a saved data in the editor , I will see this :

it s a <strong>sample </strong>entry

instead of :

it s a sample entry

is it a bug?

P.S: the used code is :
   @(Html.Telerik().EditorFor(model => model.Description)
          .HtmlAttributes(new { style = "height:150px;" }))

1 Answer, 1 is accepted

Sort by
0
Jacob
Top achievements
Rank 1
answered on 06 Jun 2011, 01:19 AM
Also experiencing the same issue, one cannot use the decode or raw call with this (maybe bug) as well...

Update: Sorted it out....
1. Do not encode your strings saving back to the db
2. Use standard binding when editing your strings
3. When displaying the content back to your "public view" then use HTML.Raw(Html.Raw(HttpUtility.HtmlDecode(model.value))) or add this to your controller classes

        public ActionResult Edit(int id)
        {
            MyClass theclass = db.test.Find(id);        
            theclass.html = System.Web.HttpUtility.HtmlDecode(theclass.html);
            return View(theclass);
        }
        public ViewResult Details(int id)
        {
            
            MyClass theclass = db.test.Find(id);
            theclass.html= System.Web.HttpUtility.HtmlDecode(theclass.html);
            return View(theclass);
        }


Hope this helps you guys, worked for me, stupid mistake from my side :-)
Tags
Editor
Asked by
mahmoud
Top achievements
Rank 1
Answers by
Jacob
Top achievements
Rank 1
Share this question
or