input onfocus="this.select();" This selects field when the field receives focus
or
document.getElementById("fieldName").select(); This highlights field
document.getElementById("FieldName").focus(); Just sets focus to field.
Tuesday, February 11, 2014
Setting focus on a Field at Program startup
The javascript Snippet:
</form>
<script
type="text/javascript"
language="javascript">
document.getElementById("YourControlName").focus();
</script>
</body>
Ensure the Following:
- The javascript is placed after the close form tag
- The javascript is placed before the close body tag
- The @Page Directive SmartNavigation is not set to true
- The YourControlName highlighted above is replaced with your control's ID value
Another Way to accomplish setting focus to a specific field:
window.onload = function() {
document.getElementById("TextBoxName").focus();
};
Subscribe to:
Posts (Atom)