The IButtonControl interface and validation

Discussion in 'ASP .Net Building Controls' started by Mark, Mar 28, 2007.

  1. Mark

    Mark Guest

    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,
    Mark, Mar 28, 2007
    #1
    1. Advertising

  2. Mark

    Raj Guest

    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,
    >
    Raj, Apr 12, 2007
    #2
    1. Advertising

  3. Mark

    Teemu Keiski Guest

    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


    --
    Teemu Keiski
    AspInsider, ASP.NET MVP
    http://blogs.aspadvice.com/joteke
    http://teemukeiski.net



    "Mark" <> wrote in message
    news:...
    > 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, Apr 15, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wildepiet
    Replies:
    0
    Views:
    1,861
    Wildepiet
    Jun 14, 2004
  2. =?Utf-8?B?RFdT?=
    Replies:
    0
    Views:
    1,877
    =?Utf-8?B?RFdT?=
    Mar 31, 2006
  3. cyberco
    Replies:
    8
    Views:
    487
    cyberco
    Feb 25, 2006
  4. Xah Lee
    Replies:
    15
    Views:
    584
    Sherm Pendley
    Mar 23, 2007
  5. daokfella
    Replies:
    0
    Views:
    363
    daokfella
    Nov 23, 2008
Loading...

Share This Page