Javascript not work after update panel is updated

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ting ting
    New Member
    • Sep 2007
    • 15

    #1

    Javascript not work after update panel is updated

    As I am using a update panel in asp.net 2.0 and a textbox inside it. I'd like the textbox remains focused after the server "postback". (that mean after the update panel is updated).

    I tried many methods but it fails. Such as : place the setCursorAtEnd javascript at the textbox when onfocus.

    [CODE=vb]Protected Sub Page_PreRender( ByVal sender As Object, ByVal e As System.EventArg s) Handles Me.PreRender

    ScriptManager.R egisterClientSc riptBlock(Me, Me.GetType(), "myfun", " function setCursorAtEnd( o){ if (o.createTextRa nge) { var r = (o.createTextRa nge());r.moveSt art('character' , (o.value.length ));r.collapse() ;r.select();}}" , True)

    End Sub
    [/CODE]
    Can anyone help? THANKS!
    Last edited by acoder; Nov 1 '07, 04:36 PM. Reason: Added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Why not use the textbox element's focus() method onload?

    Comment

    Working...