How to decode html value of editor in mvc?

Total Post:1

Points:7
C#
 422  View(s)
Ratings:
Rate this:

Hi, 

I want to decode editor value in jquery. Please give me some idea to achieve this task.

The code is as follows:

<div class="form-group">
            <label for="description">Description</label>
            @Html.TextAreaFor(x => x.Content, new { @style = "min-width: 100%;max-width: 100%", rows = "10", @class = "DescriptionEditor" })
</div>
$('#Content').summernote({
          height: 280,           callbacks: {                onPaste: function (e) {                     var bufferText = ((e.originalEvent || e).clipboardData || window.clipboardData).getData('Text');                     e.preventDefault();                     document.execCommand('insertText', false, bufferText);                 }             }  });
  1. Post:44

    Points:310
    Re: How to decode html value of editor in mvc?

    Hi Clara,

    I analyzed your code. You can easily decode your editor value by using the following line of code:

    Step 1: First of all get editor value using class name (you can also use name or id of the element).

     var editorVal = $('.DescriptionEditor').val();

    Step 2: Create a method to decode editor value.

     function DecodeHtml(str) {
    
            return $('<div/>').html(str).text();
        }

    Step 3: Call DecodeHtml method and pass the value of editor as a parameter. And save return value in the variable.

    var editorDecodeVal = DecodeHtml(editorVal).trim();

    I hope it's informative!!!



Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!