|
-
Feb 10th, 2003, 01:29 PM
#1
Thread Starter
Frenzied Member
set focus
How can I set focus to a txtbox in the page load handler?
-
Feb 10th, 2003, 03:18 PM
#2
New Member
Yes it is possible , in several ways, but the most effective is:
<FORM NAME="myFormName">
<INPUT ITEM="text" NAME="myTextField">
</FORM>
<SCRIPT LANGUAGE=JAVASCRIPT><!--
document.myFormName.myTextField.focus();
//--></SCRIPT>
It's client side script...
-
Feb 10th, 2003, 03:24 PM
#3
Thread Starter
Frenzied Member
what if it's a web control instead of a HTML control?
-
Feb 11th, 2003, 08:22 AM
#4
New Member
Sorry, send you the wrong code!
This will work, except on self-made usercontrols...
just add a 'imports system.text' line before your class dec.
add this to your startup:
Dim strBuilder As StringBuilder = New StringBuilder()
strBuilder.Append("<script language='javascript'>")
strBuilder.Append("function setFocus() {")
strBuilder.Append("document.getElementById('TextBox3').focus();}")
strBuilder.Append(" window.onload=setFocus;")
strBuilder.Append("</script>")
RegisterClientScriptBlock("Focus", strBuilder.ToString)
Good luck!
Tim.
-
Feb 11th, 2003, 08:40 AM
#5
Thread Starter
Frenzied Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|