Friday, August 18, 2006

Setting focus to a textbox from codebehind

Dim fun As String

fun = fun & "Script language='javascript'" & vbCrLf

fun = fun & "function setFocus() {" & vbCrLf

fun = fun & "document.getElementById('txtDomainName').focus();" & vbCrLf

fun = fun & "}" & vbCrLf

fun = fun & "window.onload = setFocus;" & vbCrLf

fun = fun & "/Script" & vbCrLf

RegisterClientScriptBlock("Focus", fun)


On the 2nd and 7th lines above provide angle brackets "<" or ">" accordingly as blogger is not allowing me to post like as it is ;-)

No comments: