Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Postback resets the page to the top

Status
Not open for further replies.

sheykc

Programmer
Joined
Sep 28, 2001
Messages
79
Location
US
I have several controls on my page that do a postback (dropdowns, textboxes, checkboxes, etc). I have textboxes inside my grid that once the user changes a value in the textbox, I have to recalculate other fields in the grid and on the page.

The problem is, when the postback occurs, it resets the screen to the top of the page. There are times when there will be several hundred or a thousand items in the grid (they don't want to page thru the grid), so if they are working with item #100, after tabbing out of one of the textboxes it will reset the screen to the top. Then they will have to scroll down, find where they left off and then continue. Frustrating for the user, at the very least.

What can I do to work around this behavior? Is there a way to tell .NET to go back to the last control they were working on, even after the postback occurs?

Thanks,

Shey
 
Try setting the SmartNavigation property on the Page to TRUE. However, this property is know to cause some weird problems. Try it and test your page carefully.

Jim
 
Thanks...I'll try that.

Shey
 
Code:
	Private Sub SetFocus(ByVal ctrl As Control)
    ' Define the JavaScript function for the specified control.
    Dim focusScript As String = "<script language='javascript'>" & _
      "document.getElementById('" + ctrl.ClientID & _
      "').focus()</script>"

    ' Add the JavaScript code to the page.
    Page.RegisterStartupScript("FocusScript", focusScript)
	End Sub

     Sub onTextChanged(bla bla)
     'Do your deed
     'in a datagrid
        Dim myCtrl as TextBox = dg.items(dg.EditItemIndex).FindControl("incHistDetail")
        setFocus(myCtrl)
     'not in datagrid
        setFocus(textBoxOnMyPage)
     End Sub
 
That's good to know. Thanks!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top