Link to home
Create AccountLog in
Avatar of wchh
wchh

asked on

VS.net 2008: Page up/down Key for Gridview

Please provide sample on GridView for Web Application where by press <Page up> or <Page Down> at Keyboard to navigate across the page instead of click the page number.
Avatar of Easwaran Paramasivam
Easwaran Paramasivam
Flag of India image

Avatar of wchh
wchh

ASKER

Thanks for the respond.
It seems like only workable for 'telerik: RadGrid' instead of 'asp:gridview'.
Any other suggestion?
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of wchh

ASKER

Thanks for providing link.
I started with first link as follow:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
.
.
 ClientScript.RegisterClientScriptBlock(GetType(String), "keyScript", _
             "function move(e) { " & _
             " var key = 0; " & _
             " If (window.event) Then " & _
             "    key = event.keyCode;" & _
             " Else" & _
             "    key = e.keyCode;" & _
             " if(key == 38)" & _
             "    document.getElementById('BtnUPage').click();" & _
             " if(key == 40)" & _
             "    document.getElementById('BtnDPage').click();" & _
             "}" & _
             "document.onkeydown=move; ", True)
End Sub

Private Sub BtnDPage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnDPage.Click
        Dim i As Integer = Session("IPage") - 1
        If i < Session("MaxPage") - 1 Then
            dg.PageIndex = i + 1
            Change_page(i + 1)
        End If
    End Sub

Private Sub BtnUPage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BtnUPage.Click
        Dim i As Integer = Session("IPage") - 1
        If i > 0 Then
            dg.PageIndex = i - 1
            Change_page(i - 1)
        End If
    End Sub

Open in new window


But the key Arrow Up/Down cannot capture the button...
If you put a breakpoint on button clicks, do those keys cause a post back?
Avatar of wchh

ASKER

Thanks for your response.
Sorry, no post back at button click event.
And if you put an alert in javascript function, does it come up when key pressed? What keycode you get?
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account