Saturday, March 24, 2012

set focus after postback

How can I set the focus to a control after postback?I have some javascript function to set the focus in onload event,but it looks like the onload event is not trigger after postback.ThanksThis will do what you want:
-- focus and select in a textbox
Dim sb As New System.Text.StringBuilder

sb.Append("<script language=javascript>")
sb.Append("document.forms.myForm.txtMyBox.focus();")
sb.Append("document.forms.myForm.txtMyBox.select();")
sb.Append("</script>")

If Not IsStartupScriptRegistered("MyBoxSelect") Then
RegisterStartupScript("MyBoxSelect", sb.ToString())
End If


Also, you might have a look @.view post 821121

regards

0 comments:

Post a Comment