Exact Duplicate of: http://stackoverflow.com/questions/390800/is-there-a-way-to-do-object-with-its-attributes-serializing-to-xml
Quite Ironically, it's a duplicate of the poster's previous question.
I want create an object, it contains some Validate application block attributes like: [Serializable] public class FormElement:IValidated {
[StringLengthValidator(1, 50, MessageTemplate = "The Name must be between 1 and 50 characters")]
public String username
{
get;
set;
}
[RangeValidator(2007,RangeBoundaryType.Inclusive,6000,RangeBoundaryType.Inclusive,MessageTemplate="input should be in 2007 to 6000")]
public int sequencenumber
{
get;
set;
}
[RegexValidator(@"^\d*\.{0,1}\d+$", MessageTemplate = "input value can not be empty or negative")]
public string medicalvalue
{
get;
set;
}
}
how do I serialize those attributes to xml? thanks