kamagra how much to take

Custom Field Validation With SPFieldValidationException

There was a post in the newsgroups wondering how when constructing a custom field type how one might build a small generic validation function in order to verify the harvested user input. There is provided the SPField.GetValidatedString method, which is overridable, that can be used in order to achieve this since it will take the object input provided by the custom field type and provide a workable string representation.

An example of this method is this:

  1. private readonly string m_strValidationException = "Hmmm, your string length wasen't 10!";
  3. public override string GetValidatedString(object oValue)
  4. {
  5. if (oValue.ToString().Length != 10)
  7. {
  8. throw new SPFieldValidationException(m_strValidationException);
  9. }
  11. else
  13. {
  14. return oValue.ToString();
  15. }
  17. }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>