This may seem like a simple question and I haven't been able to find an easy answer to this question. I have a Model (a view model with various pieces of data) that I'm loading into JavaScript variables as the page loads.

An example of this is:

var UserDescription = '@Model.userProfile.UserDescription';

It's working okay and the UserDescription does indeed have the text that I want it to have with one exception, I'm getting the special characters as unicode strings(I believe they're unicode strings anyways). An example is if my UserDescription contains the word 'You've' the value in UserDescription will contain 'you' followed by '&#39' followed by 've'

I did an alert and indeed the value held in UserDescription does actually contain the character string regardless of putting the data in the textarea. Just in case I'm doing something wrong here's some more of the code:

The textarea:

<textarea type="text" class="form-control" id="UserDescription">

The jquery to populate said textarea


And from my viewmodel(I have no attributes on it):

public string Description{ get; set; }

I have also looked in the database and in the database the value is correct. This seems like something that should be easy to resolve and maybe I've just been looking at code too long today but any help would be greatly appreciated.

Related posts

Recent Viewed