LoadPostData and Validation

M

Mythran

I have a control that inherits from WebControl. This control also
implements IPostBackDataHandler and IValidator (it's an amount edit [for
numeric amounts] that have format properties for positive, negative, and
zero amounts). In the LoadPostData method, should I validate the posted
value and return True only if it is value and is different than the original
value?

I have 2 properties, one of type Decimal and one of type String. The
Decimal value is the decimal representation of the value the user entered.
The String value is the formatted version of the value the user typed in...

So, the user typed in '123456.7800'. The PositiveFormat property is checked
and the Text property is set to '$123,456.78'. The Value property is set to
'123456.78'. This is fine, and my custom ValueChanged event should be
raised...so I would return True.

If the user typed in 'asdf', this is not valid. Should I still return True
and raise ValueChanged even though it is an invalid value?

Whether or not I raise the ValueChanged event, should I set the IsValid
property to True (if the value is valid) or False (if the value is not
valid) even though I have the Validate method that checks it?

Since this is not Validator control, but still implements the IValidator
interface, what should happen? (We use the IValidator interface for the
ValidationSummary control to display validation errors).

Thanks in advance,
Mythran
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,141
Messages
2,570,817
Members
47,364
Latest member
Stevanida

Latest Threads

Top