[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

The IButtonControl interface and validation

Mark

3/28/2007 1:59:00 AM

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,

2 Answers

Raj

4/12/2007 6:38:00 PM

0

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!!

"Mark" wrote:

> 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,
>

Teemu Keiski

4/15/2007 6:39:00 AM

0

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.postb...(vs.80).aspx


--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice....
http://teemu...



"Mark" <Mark@discussions.microsoft.com> wrote in message
news:BB5B1D76-2ACB-41A4-8B65-4124A8DB5EE9@microsoft.com...
> 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,
>