ASP.NET MVC 3 - How do I allow to enter in html textarea -


i want use granular data validation. [allowhtml] attribute not working formcollection. there alternative use validateinput(false)?

in metadata:

[allowhtml] [datatype(datatype.multilinetext)] [display(name = "content")] public string content { get; set; }  in edit action:  [httppost] public virtual actionresult edit(int id, formcollection formcollection) {     var obj = service.get(id);      if (modelstate.isvalid)     {         updatemodel(obj, formcollection);         service.update(obj);          return onedited(obj);     }      return view(obj); } 

you can't use allowhtml formcollection. use [validateinput] attribute disabled validation values:

[httppost] [validateinput(false)] public actionresult edit(formcollection collection, int id) {     var myentity = _myrepo.get(id);     tryupdatemodel(objective);     return dosave(objective); } 

this being said use following:

[httppost] public actionresult edit(myentity entity) {     if (modelstate.isvalid)     {         _myrepo.save(entity);         return redirecttoaction("success");     }     return view(entity); } 

a simplified reason why not work when binding formcollection because there's nothing associates fact have allowhtml defined on property of class executing request.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -