I get user input from textarea
and handle it on the server where it’s encoded with base64 and stored in a database, but for some reason there seems to be an encoding error when loading that content back into a textarea.
The problem is that i my case quotation marks ' and "
get encoded by the form but when i display my text again the encoding remains. (it looks like sometext'moretext
instead of sometext'moretext
) I wonder how can i decode the values to display correctly again.
I tried decodeURIcomponent()
but it didn’t work. I use razor pages and load data into textarea using asp-for=""
directive.
Here is my code:
<form asp-page-handler="update" id="editor" class="editor-area" method="post">
<textarea
asp-for="MainText"
class="input-editor-area"
id="input-editor"
onchange="saveDraft('@Model.Contents.Id')">
</textarea>
/* etc */
//Contents.Data is base64 encoded text
// MainText is a property with [BindProperty] attribute
MainText = Base64UrlEncoder.Decode(Contents.Data)
You need to sign in to view this answers