Quantcast
Channel: Code monkey CODE!! » EF4
Viewing all articles
Browse latest Browse all 5

Submitting html in mvc3 using AllowHtml attribute

$
0
0

Get this error in MVC httprequestvalidationexception? Think its about time you were allowed to make a call whether html type characters could be submitted in a form? Step in mvc3 and granular validation with [AllowHtml] attribute.

Its pretty simple although I have to admit was thrown by an another part of the project out of the MVC page cycle analysing the request and causing the error to be re-thrown even though i’d fixed it. Make sure you include the latest MVC dll and System.ComponentModel.DataAnnotations and just do the following.

 
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
 
public class SimpleEntity 
{
       [AllowHtml]
       public string LetThereBeHtml {get;set;}
}

If your using T4Templated generated POCO’s (and by god you should) then check my post on metadata’ing up POCOs using partials.


Viewing all articles
Browse latest Browse all 5

Trending Articles