How to: Test User Controls in Visual Studio [AX 2012]
Updated: April 26, 2011
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
When developing simple User Controls for Enterprise Portal, you may find it helpful to test and debug the controls in the ASP.NET Development Server environment. This test environment can be accessed directly from Visual Studio.
While testing simple User Controls directly from Visual Studio can make development faster, you will still want to use the actual Enterprise Portal environment to thoroughly test User Controls that you create or modify.
To test User Controls in the ASP.NET Development Server environment, you must do the following:
Open the Default.aspx page that is part of your EP Web Application project. This is an ASP.NET page that can host web parts needed for testing User Controls. The Default.aspx page is automatically included in any EP Web Application project you create.
Configure the web parts on the Default.aspx page.
Add any EP Proxy Projects that are required for your EP Web Application project.
Run the Default.aspx page.
The Default.aspx page will already contain several components. The ScriptManager and WebPartManager components provide capabilities needed for the page to display web parts. The page will also contain an AxInfolog and an AxUserControlWebPart. These components display an Infolog web part and a User Control web part, just as a page in Enterprise Portal would. You can add more User Control web parts to this page so that it will operate in a similar manner to a page in Enterprise Portal.
To configure web parts on the Default.aspx page
Specify the User Control to be displayed on the web page. Select the AxUserControlWebPart on the page, and set the Managed Web Content Item property to specify the User Control to be displayed on the page. The AxUserControlWebPart is the last item in the Body group on the page.
The User Control must have already been added to the current project.
If several User Controls will be used together on the page, add more User Control web parts. To add more web parts, you must manually add them to the markup for the page. See AxUserControlWebPart for more information about how to add an AxUserControlWebPart to the markup.
If any one of the User Controls on the Default.aspx page uses proxies to access X++ code, the EP Proxy Project that defines the proxies must be added to the EP Web Application project.
To add an EP proxy project
In the Project menu, choose Add EP Proxy Project. A dialog box will be displayed that lists all of the proxy projects that have been added to the AOT. The EPApplicationProxies project is the most frequently used proxy project. It contains definitions for several enums, classes, and tables that are frequently used in code for User Controls.
Select the proxy project that is accessed by your User Control, and then click OK. The proxy project will be added to the solution, and a reference to the proxy project will be created.
If a proxy is needed but has not been added to your EP Web Application project, the EP Web Application project will have build errors.
After the Default.aspx page has been designed and configured, it can be run in the ASP.NET Development Server environment.
To run the Default.aspx page
In the Build menu, click Build Solution. The EP Web Application project should build without errors. If errors are found, correct them and build again.
Be sure the Default.aspx page is open and active in Visual Studio.
In the Debug menu, click Start Debugging. After several moments, a web browser will appear and display the content of the Default.aspx page.
Test the controls on the page.
When you have finished, close the web browser window to stop debugging and return to Visual Studio.