c# - How to store HTML code in ASP.NET MVC2 Model -


i have comment model string property this:

[column] public string text { get; set; } 

comment text can have html tags inside (i know it's bad, have to). when update object, mvc 2 escapes html tags.

updating method is:

[httppost] public actionresult edit(int id=0) {         comment comment= id == 0             ? new comment ()             : commentrepository.comments.first(x => x.id == id);          tryupdatemodel(comment);          if (modelstate.isvalid)         {             commentrepository.save(comment);             return redirecttoaction("view/" + comment.id);         }         else         {             return view(comment);         }     } 

how can update comment text without escaping?

p.s. have problem column type: when switch column text in sql server express varchar text, updating model fails:

the data types text , nvarchar incompatible in equal operator.

exception details: system.data.sqlclient.sqlexception: data types text , nvarchar incompatible in equal operator.

what have turn off validation particular input field. can add filter action:

[validateinput(false)] 

or if want specific , turn off on 1 field (maybe work on multiple, haven't tested though) this:

[validateinput(true, exclude = "yourfieldname")] 

this exclude field still check other fields.

addon: adding filters ca done in (afaik) 2 way. here 2 samples:

[httppost, validateinput(true, exclude = "yourfieldname")] public actionresult someaction(...) { ... }  [httppost] [validateinput(true, exclude = "yourfieldname")] publiv actionresult someaction(...) { ... } 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -