ASP.NET MVC3 - Display accented string in TextBoxFor -


i'm working on asp.net mvc3 project.

in basic update page, i'm trying display data recorded in db textboxfor. however, data can contain special characters, quote ' or accented letters é

when write

@html.textboxfor(m => m.myproperty) 

the displayed text looks l'avée instead of l'avée.

i've seen this question answer doesn't change me.

is there way display string properly accented letters , quotes in textboxfor ?

update

this field in partial view containing field :

@model myapp.models.somemodel  <div class="form-group">     @html.labelfor(m => m.mymodel.submodel.myproperty)     @html.textboxfor(m => m.mymodel.submodel.myproperty, new { @class = "form-control", @id = "txtmyproperty" })*@ </div> 

here, somemodel correctly displayed (believe me).

  • somemodel has mymodel property.
  • mymodel has somemodel property
  • somemodel has myfield field.

everything correctly filled db (believe me, has been tested , re-tested). however, can't correctly display myfield if has special characters. displayed, html reprensentation &#39;

the link provided in comments correct answer.

@html.textbox("test", httputility.htmldecode(model.myproperty)) 

works correctly.

my view

@model mvcapplication1.models.somemodel  @{     viewbag.title = "title"; } <h2>title</h2> @{ html.renderpartial("partial"); } 

my partial view

@model mvcapplication1.models.somemodel  <div class="form-group">      @{          model.myproperty = system.web.httputility.htmldecode(model.myproperty);      }     @html.labelfor(m => m.myproperty)     @html.textboxfor(m => m.myproperty, new { @class = "form-control", @id = "txtmyproperty" }) </div> 

my controller

   public class homecontroller : controller     {         public actionresult index()         {             somemodel model = new somemodel                 {                     myproperty = "l&#39;av&#233;e"                 };             return view(model);         }       } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -