I need CausesValidation on Paging

Discussion in 'ASP .Net Datagrid Control' started by Mehdi, May 23, 2004.

  1. Mehdi

    Mehdi Guest

    Hi,

    Does anyone know how to set Causesvalidation =true; when paging. I need to
    call my custom validator.

    Thanks for the help in advance.

    Regards


    Mehdi
    Mehdi, May 23, 2004
    #1
    1. Advertising

  2. Mehdi

    Rick Spiewak Guest

    There is a little bit of guesswork involved in this <g>:

    Here are the attributes I found in the rendered HTML of a button which
    causes validation.
    onclick="if (typeof(Page_ClientValidate) == 'function')
    Page_ClientValidate(); " language="javascript"

    Based on the above, I would try putting the following in the ItemCreated
    event for the datagrid:

    Dim dg As DataGrid = DirectCast(sender, DataGrid)
    Dim itm as DataGridItem = e.Item
    If itm.ItemType <> ListItemType.Pager Then Exit Sub
    ' This code will only work for numeric pager style, not NextPrev
    If dg.PagerStyle.Mode <> PagerMode.NumericPages Then Exit Sub
    Dim dglb As LinkButton
    If dg.DataSource Is Nothing Then Exit Sub
    For i As Integer = 0 To itm.Cells(0).Controls.Count - 1
    Dim c As Control = itm.Cells(0).Controls(i)
    If c.GetType.ToString =
    "System.Web.UI.WebControls.DataGridLinkButton" Then
    dglb = DirectCast(c, LinkButton)
    dglb.Attributes.Add("onclick", "if
    (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); ")
    End If
    Next i
    End If

    "Mehdi" <> wrote in message
    news:OHVc$...
    > Hi,
    >
    > Does anyone know how to set Causesvalidation =true; when paging. I need

    to
    > call my custom validator.
    >
    > Thanks for the help in advance.
    >
    > Regards
    >
    >
    > Mehdi
    >
    >
    Rick Spiewak, May 24, 2004
    #2
    1. Advertising

  3. Mehdi

    Mehdi Guest

    Thanks Rick,

    I will try it.
    Mehdi, May 24, 2004
    #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. Josh Anderson - remove Zs to reply

    CausesValidation not taking in Repeater control

    Josh Anderson - remove Zs to reply, Nov 20, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    371
    Josh Anderson - remove Zs to reply
    Nov 20, 2003
  2. George Durzi

    CausesValidation of editcommandcolumn

    George Durzi, Feb 12, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    969
    George Durzi
    Feb 12, 2004
  3. z. f.
    Replies:
    4
    Views:
    1,351
    z. f.
    Jun 23, 2004
  4. z. f.
    Replies:
    4
    Views:
    2,263
    Peter Blum
    Jun 25, 2004
  5. Martin
    Replies:
    3
    Views:
    766
    Peter Blum
    May 21, 2005
Loading...

Share This Page