Regarding Page_ClientValidate() function

Discussion in 'ASP .Net' started by =?Utf-8?B?RGVlcHNvbiBUaG9tYXM=?=, May 12, 2006.

  1. Hi,
    How can we identify due to which validator control the
    Page_ClientValidate() method is returning false.

    why iam asking this coz in my page iam using lotz of regular expression
    validators and on the click of button if iam checking whatz the return value
    of Page_ClientValidate() function iam getting false.

    Now on click of a checkbox i disables a couple of textboxes. i attached
    regular expression validators to these textboxes. if these textboxes are
    enabled and contains proper data then also Page_ClientValidate() function
    returns false. even i wont get any message from the validators. if i clicked
    on the checkbox and disable the textboxes then Page_ClientValidate()
    function returns true.

    can anybody tell me whatz really wrong...

    waiting for the reply.

    --
    Deepson Thomas
     
    =?Utf-8?B?RGVlcHNvbiBUaG9tYXM=?=, May 12, 2006
    #1
    1. Advertisements

  2. =?Utf-8?B?RGVlcHNvbiBUaG9tYXM=?=

    Brock Allen Guest

    You can iterate over the Page.Validators collection manually and check IsValid
    to identify which one(s) are failing.

    -Brock
    http://staff.develop.com/ballen


    > Hi,
    > How can we identify due to which validator control the
    > Page_ClientValidate() method is returning false.
    > why iam asking this coz in my page iam using lotz of regular
    > expression validators and on the click of button if iam checking whatz
    > the return value of Page_ClientValidate() function iam getting false.
    >
    > Now on click of a checkbox i disables a couple of textboxes. i
    > attached regular expression validators to these textboxes. if these
    > textboxes are enabled and contains proper data then also
    > Page_ClientValidate() function returns false. even i wont get any
    > message from the validators. if i clicked on the checkbox and disable
    > the textboxes then Page_ClientValidate() function returns true.
    >
    > can anybody tell me whatz really wrong...
    >
    > waiting for the reply.
    >
     
    Brock Allen, May 13, 2006
    #2
    1. Advertisements

  3. =?Utf-8?B?RGVlcHNvbiBUaG9tYXM=?=

    Saurabh Pant

    Joined:
    Jun 22, 2007
    Messages:
    1
    Likes Received:
    0
    Page_ClientValidate Validation check

    This can be achieved easily by having diffferent controls(Button, checkbox, etc.) set their ValidationGroup property set to some value. Match this with the ValidationGroup property of the Validators(CustomValidator, RequireFieldValidator, etc.) Next, write your javascript functions to do something on different events of the control(OnClick, etc.) and add the 'Page_ClientValidate' check to see if the validations(Custom, RequireField) are complete in the page. Example below, will display confirm message for btn1 click, if validations associated with it are complete, and NOT btn2 validations. You can also use Page_ClientValidate(' '); with empty string, if you want to check for the controls validations with no ValidationGroup assigned.

    function btnOnClick(){
    var validated = Page_ClientValidate('group1');
    if (validated){
    return confirm('Are you sure you want...');
    }
    }

    <asp:Button ID="btn1" runat="server" ClickOnce="true" Text="ClickMe" CausesPostback="true" CausesValidation="true" ValidationGroup="group1" OnClientClick = "return btnOnClick();"/>

    <asp:Button ID="btn2" runat="server" ClickOnce="true" Text="ClickMe" CausesPostback="true" CausesValidation="true" ValidationGroup="group2" OnClientClick = "return btnOnClick();"/>

    Happy Programming!
     
    Last edited: Jun 22, 2007
    Saurabh Pant, Jun 22, 2007
    #3
  4. =?Utf-8?B?RGVlcHNvbiBUaG9tYXM=?=

    ademoo

    Joined:
    Aug 22, 2008
    Messages:
    1
    Likes Received:
    0
    i've read this topic and it saved my life :) thanks for this one.
     
    ademoo, Aug 22, 2008
    #4
    1. Advertisements

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. Ante Perkovic

    How to get rid of Page_ClientValidate() ?

    Ante Perkovic, Jul 1, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    6,476
    William F. Robertson, Jr.
    Jul 1, 2003
  2. James Vanns
    Replies:
    7
    Views:
    7,677
    Evan Carew
    Jan 21, 2004
  3. komal
    Replies:
    6
    Views:
    1,720
    msalters
    Jan 25, 2005
  4. Replies:
    2
    Views:
    1,137
    Bengt Richter
    Aug 1, 2005
  5. Giannis Papadopoulos

    Function pointer to void function and int function

    Giannis Papadopoulos, Sep 5, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,526
    Barry Schwarz
    Sep 5, 2005
  6. Bob
    Replies:
    6
    Views:
    3,222
  7. weafon
    Replies:
    1
    Views:
    539
    Diez B. Roggisch
    Jul 14, 2009
  8. Alf P. Steinbach
    Replies:
    10
    Views:
    4,020
    Alf P. Steinbach
    Jul 27, 2011
Loading...