Setting Focus in Application Pages

Iron Speed Designer applications have functionality to set focus to a certain control on initial page load and set the focus to a new added row in editable tables. 

Important: if you use .NET Framework 3.5 the set focus functionality requires Service Pack1 to be installed to operate properly.

Every page calls SetFocusOnLoad on every load.  It is declared overridable (virtual) and can be overridden on any page.  It is located in:

..\<APP NAME>\Shared\BaseApplicationPage.cs (.vb)

It is called in the Section 1 of page’s code behind file, e.g.:

..\<APP NAME>\Customers\ShowCustomersTable.aspx.cs (.vb)

SetFocusOnLoad loads a script which is executed on initial load.  You may pass control to this method to set focus on the initial load to this specific control. This script in turn calls the setFocus method defined in:

..\<APP NAME>\SetFocus.js

By default, pages set the focus to the first focusable element on the page.  Focusable elements are typically text boxes or dropdown lists.  However, your application will not set the focus to the FCKeditor control because of the asynchronous behavior of this control.

An application sets focus only to elements inside the page content area based on the default content placeholder names used by your application’s master page.  This check is based on default content placeholder names.  If you change the name of a content placeholder in the Application Generation Options dialog, you should modify the ApplicationWebForm.js file located in your application’s root folder, e.g.:

..\<APP NAME>\ ApplicationWebForm.js

By modifying this file, you can:

Special code is created to set focus to the first focusable element of a newly added row in editable table panels.  For web applications, this functionality is located in the SetFocusToAddedRow method, which is called from the DataBind method in the table control class in the Controls.cs (.vb) file is located in:

..\<APP NAME>\Customers\ShowCustomersTable.Controls.cs (.vb)

For web sites, the SetFocusToAddedRow is located in:

..\<APP NAME>\App_Code\Customers\ShowCustomersTable.Controls.cs (.vb)

Instructions for this are also in ApplicationWebForm.js.