Building Microsoft ASP.NET Applications for Mobile Devices, Second Edition [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Building Microsoft ASP.NET Applications for Mobile Devices, Second Edition [Electronic resources] - نسخه متنی

Andy Wigley; Peter Roxburgh

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
توضیحات
افزودن یادداشت جدید






Chapter 7: Using the Downloadable Controls

Chapter 21 and Chapter 22.


Using the Custom Controls


The controls described in this chapter are all available from the Microsoft ASP.NET Web site, at http://www.asp.net. The Microsoft ASP.NET Web site provides a vast amount of information about ASP.NET for desktop and mobile browsers, including a control gallery of custom controls. Click the Control Gallery tab on the main page, and then click the Mobile Controls link to navigate to the controls, as shown in Figure 7-1.


Figure 7-1: Custom mobile controls are downloadable from http: //www.asp.net and other sources on the Web.

Download the zipped controls and read their installation instructions. Copy the assembly for each control to an accessible directory; the supplied installation instructions suggest the C:\Inetpub\wwwroot\bin directory, which is a good location if you only want to install the custom controls on your own development machine. (C:\Inetpub\wwwroot\bin is not a standard directory created when you install IIS on your computer, so you'll need to create it if this is where you want to install the custom controls.) Alternatively, if you want to make the controls available to a group of developers, you could copy them into a directory on a network share.

All three controls work with both Microsoft .NET Framework 1.0/Mobile Internet Toolkit 1.0 and Microsoft .NET Framework 1.1.


Adding the Controls to the Toolbox


If you're using Microsoft Visual Studio .NET, it's a good idea to add the custom controls to the Toolbox. You can then drag a custom control from the Toolbox onto your Web Form page just as you would any other control; Visual Studio .NET will automatically take care of much of the additional configuration steps you must perform to make use of a custom control.

To add a custom control to the Toolbox, follow these steps:



Open a Mobile Web Application project in Design mode.



Right-click on the Toolbox, and select Add/Remove Items… as shown in Figure 7-2.


Figure 7-2: Customizing the Toolbox



In the Customize Toolbox window, select the .NET Framework Components tab.



Browse for the compiled control—for example, c:\inetpub\wwwroot\ bin\MobileDynamicImage.dll.



In the Open dialog, select the control and click Open. The control is added to the .NET Framework Components list, as shown in Figure 7-3. Click OK to confirm the addition.


Figure 7-3: Selecting the assembly containing the custom



If you move the custom controls from the directory where you originally installed them to a new location, you will have to remove these controls from the Visual Studio .NET Toolbox and add them again so that the Visual Studio .NET Toolbox knows where to find the control assemblies when you drag one of these controls onto a project.


Copying the Control Assembly to Your Application


If you have customized the Visual Studio .NET Toolbox so that it includes one or more of the custom controls, you can now drag the custom controls from the Toolbox onto a Web Forms page, just as you do with other controls. Visual Studio .NET adds the required declarations to your .aspx file and copies the control assembly (for example, MobileCheckbox.dll) into the /bin directory of your application. Visual Studio .NET also adds a reference to the control's assembly to your project, which is required for the project to compile correctly.

If you're not using Visual Studio .NET or you have not customized the Toolbox, you must manually copy the assembly into your application's /bin directory and then add a reference to the head of the .aspx file, as shown here for the MobileCheckbox:

<%@ Register TagPrefix="mobCB" Namespace="MobileCheckbox"
Assembly="MobileCheckbox" %>

You can then use the MobileCheckbox control in server control syntax, by specifying the TagPrefix you just defined (mobCB in this example) followed by the name of the control class (Checkbox for the MobileCheckbox control), as shown here. We describe the complete server control syntax for the MobileCheckbox in the next section.

<mobCB:Checkbox id="Checkbox1" runat="server" …></mobCB:Checkbox>

You must also add a reference to the control assembly to your Visual Studio .NET project by right-clicking on the project in Solution Explorer, selecting Add Reference, clicking the Browse button, and then navigating to the control assembly (for example, MobileCheckbox.dll) in your application /bin directory.


Configuring Your Application to Use Custom Controls


You must ensure that any required configuration changes are made to the <mobileControls> section of your ASP.NET application's web.config configuration file. (See the section "Configuring Your Application" for each control described in this chapter for more details about the precise configuration required by each control.) You can make the configuration changes in the application's Web.config file (located in the application directory) so that the change applies only to that application. (The Web.config file that Visual Studio .NET generates for you already contains a <mobileControls> section, so be sure to merge this new XML into that section instead of creating a new <mobileControls> section, which will cause a run-time error.)

Instead of making the changes in each application, you can do this just once in the machine.config file in drive:\\Windows\Microsoft.NET\version\CONFIG. This saves you having to make the change in the Web.config file of every mobile Web project that uses the controls but is not recommended because it can cause difficulties when you're deploying an application to a production Web server. It's much easier to make the configuration changes in the application Web.config file because this file ships with the application instead of trying to alter the machine.config file of a production Web server. If you make an error in a server's machine.config file, you can stop all ASP.NET applications on that server from operating!

/ 145