I need CausesValidation on Paging

M

Mehdi

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
 
R

Rick Spiewak

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top