Clientside validation for DataGrid's text boxes

Discussion in 'ASP .Net' started by Kris, Jun 30, 2005.

  1. Kris

    Kris Guest

    Hi,
    I have a DataGrid where in each row has couple of text boxes and an
    update button. Each row is dynamically generated as the number of rows
    are not known ahead of time. When the user clicks the update button, I
    do a postback to capture the data entered. However I dont want to do a
    postback when the textboxes are empty. How do I prevent this using
    Clientside validation? This is a common problem and if it has been
    beaten to death, please bear with me as I am new to Web Development.
    Thanks in advance for any tips or pointers.

    Kris.
    Kris, Jun 30, 2005
    #1
    1. Advertising

  2. Kris

    Peter Blum Guest

    Use the RequiredFieldValidator on each textbox.

    If you have multiple rows, each showing textboxes at the same time and you
    only want the row being submitted to validate, you need "validation groups".
    This is a feature introduced in ASP.NET 2.0 and already in my Professional
    Validation And More (http://www.peterblum.com/vam/home.aspx) which is a
    replacement to the Microsoft validators that greatly expands the
    capabilities of validation and improves data entry web forms.

    Validation groups lets you assign a group name to a submit button and its
    list of validators so it only fires the validators on its list. My
    Professional Validation And More is available for ASP.NET 1.x and does this
    task better than ASP.NET 2.0's validators because it can automatically
    create unique group names for each row in the datagrid.

    Remember to always support server side validation by testing Page.IsValid is
    true in the post back event handler for the submit button that validates.

    --- Peter Blum
    www.PeterBlum.com
    Email:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    "Kris" <> wrote in message
    news:...
    > Hi,
    > I have a DataGrid where in each row has couple of text boxes and an
    > update button. Each row is dynamically generated as the number of rows are
    > not known ahead of time. When the user clicks the update button, I do a
    > postback to capture the data entered. However I dont want to do a postback
    > when the textboxes are empty. How do I prevent this using Clientside
    > validation? This is a common problem and if it has been beaten to death,
    > please bear with me as I am new to Web Development. Thanks in advance for
    > any tips or pointers.
    >
    > Kris.
    Peter Blum, Jun 30, 2005
    #2
    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. Eddie Dodd

    Clientside validation not working

    Eddie Dodd, May 26, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    468
    Eddie Dodd
    May 27, 2004
  2. Dennis Calla

    Clientside validation not working.

    Dennis Calla, Jan 13, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    429
    Peter Blum
    Jan 13, 2005
  3. Paul
    Replies:
    1
    Views:
    2,080
    Scott Allen
    May 25, 2005
  4. MattC
    Replies:
    1
    Views:
    421
    Peter Blum
    Jul 22, 2005
  5. Stefan Mueller
    Replies:
    5
    Views:
    12,377
    jamesxa
    Jun 16, 2009
Loading...

Share This Page