PDA

View Full Version : how can i set focus without also scrolling?


threeo
12-13-2005, 09:15 AM
i am using a datagrid and a template column to let users edit some data. when the user clicks "edit" it opens up a text box. i needed a way to have the focus automatically set in the textbox after they click edit. i use this method:

RegisterStartupScript("focus", "<script language=""JavaScript"">" & vbCrLf & _

vbTab & "Form1." & normtypeTB.ClientID & ".focus();" & _

vbCrLf & vbTab & "Form1." & normtypeTB.ClientID & ".select();" & _

vbCrLf & "<" & "/script>")

this works fine except for one thing: the page scrolls and always positions the textbox directly above the task bar. this is irritating. for example, the item that the user wants to edit could be situated right in the middle of the screen. they click edit and the item goes into edit mode but now it appears at the bottom of the screen.

anyone know how i can prevent it from doing that? anyone know why that script causes the scroll?

i am not using v2 so i can't use the "maintainscreenposition" and i can't use smartnav because it screws up other things.

threeo