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();
};

No comments:

Post a Comment