ASP.NET Mobile Designer
Working with Emulators and Browsers

The ASP.NET mobile controls enable you to develop applications for a wide variety of mobile devices. The manufacturers of most mobile devices provide emulators that simulate the operation of their hardware and browsers. Emulator software enables you to view your ASP.NET mobile Web Forms application as it might appear on the manufacturers' hardware devices.

Developing and testing with emulators in addition to actual devices enables you to test your mobile Web application more easily before you deploy it.

Note   You can test your application on a local host when using emulator software. To >view ASP.NET mobile Web applications with actual devices requires that the application host be accessible from the Internet.

To view a mobile Web Forms application on an emulator, first compile the application. Next, enter the URL of the application's start page into the appropriate place in the emulator's browser. After you enter the application's URL into the emulator, your application should operate as it would on the actual hardware device. For information about using an emulator, see to the emulator documentation. For information about emulators that work with the ASP.NET mobile controls, see >Supported Devices.

Using Emulators with Visual Studio

When you run your application in Microsoft Visual Studio, Visual Studio uses a built-in browser as the default application browser. You can alter this default so that Visual Studio invokes a mobile device emulator instead. In addition, Visual Studio provides you with the ability to easily select a different current device emulator to act as the default application browser. To do so, you must obtain the device emulators from the mobile device hardware manufacturers, and install them on your development computer.

Visual Studio launches the application browser in debugging mode whenever you press the F5 key on your keyboard or choose Start from the Debug menu. Most emulators support command-line arguments. If you select an emulator as the default application browser, Visual Studio passes the emulator the command-line arguments that you specify. When you run the emulator, Visual Studio enters debug mode. Upon termination of the emulator, Visual Studio returns to design mode.

If you select an emulator as the default application browser, and the emulator does not support command-line arguments, you must supply the information each time you run the application. This can include the URL of the application's start page.

To install an emulator as the Visual Studio application browser

  1. Install and test the mobile device emulator on your development computer. See the emulator's documentation for instructions.
  2. From the File menu, select Browse With. Visual Studio displays the Browse With dialog box.
  3. Click the Add button to display the Add Program dialog box.
  4. In the Program name field, enter the name of the emulator software's executable program file. Alternatively, select the Browse button to browse to the file's location.
  5. If the emulator supports command-line arguments, supply them in the Program name field. For example, you can specify the starting URL of the application, select a "skin" for the browser, or supply other start-up information that your browser might use. For more information about skins and specific start-up information, see your emulator's documentation.
    1. Use the %URL variable to specify where the application's start page should be substituted on the command line. This variable name is case sensitive.
    2. If supported, specify a skin name. Testing with multiple skins requires multiple instances of the emulator in the browser list.
    3. Supply any other arguments the emulator needs. See your emulator's documentation for details.
  6. In the Add Program dialog box's Friendly name field, type the name of the browser as you would like it to appear in Visual Studio.
  7. Click OK to close the Add Program dialog box.
  8. In the Browse With dialog box, select the emulator from the list of browsers, and click the Set as Default button. Click Close to close the Browse With dialog box.
    Note   After you add an emulator to the list of browsers, you cannot modify its settings. You must delete it and add it again with the new settings.
  9. In the Solution Explorer, click on the name of the project file.
  10. From the Project menu, select Properties. The Property Pages dialog box appears.
  11. Click Configuration Properties.
  12. In the list of configuration properties, select Debugging. The dialog box displays the debugging configuration properties in the right-hand box.
  13. Set the Always use Internet Explorer property to False.

To change the current default application browser

  1. In the Solution Explorer, click on the name of the project file.
  2. From the Project menu, select Properties. The Property Pages dialog box appears.
  3. Click Configuration Properties.
  4. In the list of configuration properties, select Debugging. The dialog box displays the debugging configuration properties in the right-hand box.
  5. If the Always use Internet Explorer property is set to True, change it to False.
  6. Right-click the name of any .aspx file in the Solution Explorer's window.
  7. From the shortcut menu, select Browse With. The designer displays the Browse With dialog box.
  8. Select an emulator from the browser list and click the Set as Default button.
  9. Click the Close button to close the Browse With dialog box. When you next run your application, Visual Studio invokes the newly selected emulator.

To remove an emulator from the browser list

  1. Right-click the name of any .aspx file in the Solution Explorer's window.
  2. From the shortcut menu, select Browse With. The designer displays the Browse With dialog box.
  3. Select an emulator from the browser list.
    Caution   Be sure that the emulator is not the default browser. If it is, choose a different browser to be the default and click the Set as Default button.
  4. Click the Remove button. The designer deletes the emulator name from the browser list.

Configuring Emulators with Command-Line Arguments

Many mobile device emulators support command-line arguments. Visual Studio can use this feature to simplify the use of emulator programs. When you add an emulator to the list of browsers in the Browse With dialog box, Visual Studio identifies it by its name and command-line arguments. As a result, you can insert multiple instances of an emulator into the list if the command-line arguments are different for each instance. A common use of this ability is to add multiple instances of an emulator to the browser list and pass each instance a different URL.

To add an emulator to the list of available browsers

  1. Install the mobile device emulator on your development computer. See the emulator's documentation for instructions.
  2. From the File menu, select Browse With. Visual Studio displays the Browse With dialog box. Alternatively, right-click the name of any .aspx file in the Solution Explorer's window and select Browse With from the shortcut menu.
  3. Click the Add button to display the Add Program dialog box.
  4. In the Program name field, enter the name of the emulator software's executable program file. Alternatively, select the Browse button to browse to the file's location.
  5. Supply the command-line arguments in the Program name field.
    1. Use the %startpage variable to specify where the application's start page should be substituted in the command line.
    2. If supported, specify a skin name. Multiple skins require multiple instances of the emulator in the browser list.
    3. Supply any other arguments the emulator needs. See your emulator's documentation for details.
  6. In the Add Program dialog box's Friendly name field, type the name of the browser as you would like it to appear in Visual Studio.
  7. Click OK to close the Add Program dialog box.
  8. Click Close to close the Browse With dialog box.

To select a browser for viewing an application

  1. From the File menu, select Browse With. Visual Studio displays the Browse With dialog box. Alternatively, right-click the name of any .aspx file in the Solution Explorer's window and select Browse With from the shortcut menu.
  2. Click the browser name in the list of browsers.
  3. Click the Browse button.

See Also

>Requirements and Supported Devices | >Viewing ASP.NET Mobile Web Applications | Working with Environment Tools

Page view tracker