The IButtonControl interface and validation

M

Mark

Hi,

Could some-one provide an example implementation of the CasuesValidation and
ValidationGroup properties that one should implement when using the
IButtonControl interface?

I have a custom control which implements this interface and provides the
required properties but does not fire the client-side validation.

I have also noticed that the necessary client-side field (as would be
rendered by using the ClientScriptManager >> RegisterForEventValidation) is
present.
I must be missing something obvious here.

Regards,
 
R

Raj

Hi Mark,
I have been trying to implement the IButtonControl.Click but am not
able to make that work. I have also not been able to find and
links/references that mght be of some help. Can you please provide some clue
on how to implement IButtonControl. Also, if possible, please provide some
interne references/book references that might be of use in this regard.

Thanks!!
 
T

Teemu Keiski

Hi,

with for example Button there's nothing magical in the properties itself.
CausesValidation is just a standard server-side property utilizing
ViewState, and so is ValidationGroup. You also need to attach the correct
client-script to the control, just tweakinbg the properties isn't enough
with a custom control.

These properties are used to check a) If Button has Causesvalidation set and
b) also the name of the ValidationGroup. First a PostBackOptions class is
instantiated and asked it's PerformValidation and ValidationGroup properties
are set based on settings on the Button control.

The instance of PostBackOptions is then passed to
Page.ClientScript.GetPostBackEventReference to get the correct client-side
script which is appended to the rendered markup of the control (in
AddAttributesToRender). E.g this is dealt with at render time in the
control.

So, what you need to do is:

- instantiate a PostBackOptions class in your control and set its properties
- grab the correct client script call with
Page.ClientScript.GetPostBackEventReference (pass postbackoptions instance
in) and render that within your control
-Also register for event validation with
Page.ClientScript.RegisterForEventValidation (also pass instance in)

For more information, please see:

http://msdn2.microsoft.com/en-us/library/system.web.ui.postbackoptions(vs.80).aspx
 

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
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top