onfocus

  • Thread starter Thread starter amy
  • Start date Start date
If you want to set focus to a textbox you do like this

In the top of the aspx.vb you place:

Imports System.text

on page load, for example you do this:

dim str as new stringbuilder
str.append("<script language='javascript'>")
str.append("document.getElementById('Textbox1').focus();")
str.append("</script>")
registerstartupscript("Focus",str.tostring)
The first paramenter in the registerstartupscript is only
a key to the script taht you register in your page.

You can use the IsStartupScriptRegistered("Focus") to
know if your script is already register in your page, to
prevent you from writing the code all over again.

I hope this help you.

Ana Rita
 
Back
Top