Pages

Thursday, November 27, 2008

Set focus on a particular field on an EP page

With the AX 2009 Enterprise Portal you now have an easy way to set focus on a particular field on a page.

These are the steps you need to go through:
  1. The field must be created as or converted to a TemplateField. The "Dynamics AX Bound Field Designer" helps you to that. Add the field to the "Selected Field" list, make it active and click "Convert to Template field"
  2. Switch to the Source view of the page.
  3. It seems like you have to add the label of the fields yourself. This is done by adding the following section to the XML of the TemplateField: HeaderText="<%$ AxLabel:@SYSxxxxx %>
  4. Finally add code to set the focus:

    TextBox TextBox = (TextBox)this.AxGroup1.FindControl("TextBox1");
    if (TextBox != null)
    {
    TextBox.Focus();
    }