Saturday, May 18, 2019

Wcf services, data access, and other features

5.1 IntroductionMicrosoft Windows Communication stern ( WCF ) is one of the cardinal engineerings available in.NET Framework 3.0 and ulterior versions. This session briefly introduces an overview of WCF expediencys. The session in sum upition takes a expression at the spic-and-span datas think masterys in ASP.NET 3.5. As organisations grow planetary, there is a sacrosanct demand for weave occupations to accommodate to planetary audiences and civilisations. This session describes globalisation and besides discusses the support for handiness in ASP.NET 3.5. Fin tot bothyy, the session explains about peregrine applications in ASP.NET 3.5.5.2 WCF returnssWCF is designed as incorporate programming theoretical account that helps to chip in distributed applications utilizing assorted.NET engineerings such(prenominal)(prenominal) as utilizing weathervane services, .NET Remoting, Message Queue ( MSMQ ) , Enterprise Services, and so forth. Through WCF, you croupe make a indi vidual service that target be bring outd as peed pipes, HTTP, TCP, and so on.5.2.1 qualification a WCF Service with ASP.NETASP.NET and visual studio 2008 enable you to make and devour WCF services. The first measure towards this is to particularize the service squelch.The stairss to specify a service melt off atomic number 18 as follows1. Launch Ocular studio apartment and choose a new tissue on a lower floortaking of type WCF Service lotion. This guide defines a electronic network undertaking for hosting the WCF service and leave make a mention to System.Service sample.dll in the undertaking. This assembly contains the WCF categories. The undertaking templet testament besides bring forth a default service listd Service1.svc and a related find charge up piddled IService1.cs. You send word rename these two agitates suitably. For illustration, you could call the undertaking as TestServices and the service itself as NewService.The contract commove, INewService.c s, is a.NET Framework interf weft up that admits the service property contoures for the service course of study, the operations, and the members. The.svc.cs file is a crime syndicate implementing this interface. A WCF Service application is mechanically con predictd so that it corporation be hosted in IIS. It exposes a standard HTTP intercept point. The & lt system.servicemodel & gt atom of the web.config file describes these scenes.An illustration of & lt system.servicemodel & gt subdivision in web.config is shown in enter snippet 1.Code snippet 1& lt system.serviceModel & gt & lt services & gt & lt service name= TestServices.NewService behaviorConfiguration= TestServices.NewService & gt & lt endpoint address= binding= wsHttpBinding contract= TestServices.NewService.INewService & gt & lt individuality & gt & lt dns grade= localhost / & gt & lt / individuation & gt & lt /endpoint & gt & lt endpoint address= mex binding= mexHttpBinding contract= IMetadataExchange / & gt & lt /service & gt & lt /services & gt & lt behaviours & gt & lt serviceBehaviors & gt & lt behavior name= TestServices.NewServiceBehavior & gt & lt serviceMetadata httpGetEnabled= original / & gt & lt serviceDebug includeExceptionDetailInFaults= false / & gt & lt /behavior & gt & lt /serviceBehaviors & gt & lt /behaviors & gt & lt /system.serviceModel & gt 2. Implement the service contract. To implement the service, you start by specifying the contract via the interface. For illustration, see a scenario where you pauperism to expose methods of a service that work with the Suppliers table in a Shipments database. Make a Supplier family unit interior ISupplierService.cs and tag it as a infoContract and taging distributively of its members as dataMember. Code snip 2 shows an illustrationCode Snippet 2 DataContract overt category Supplier// specify a guardianship DataMember public int SupplierCode get delineate // define forme r(a) belongingssThe following measure is to specify the methods of your interface in ISupplierService.cs and tag them with the OperationContract property. You need to tag the interface with the ServiceContract property as shown in Code Snippet 3.Code Snippet 3 ServiceContract public interface ISupplierService OperationContract Supplier GetSupplier ( int supplierCode ) OperationContract Supplier SaveSupplier ( Supplier supplierper ) WCF will utilize the interface to expose a service. The service will be configured based on the web.config file.The service interface is implemented wrong the ISupplierService.svc.cs file as shown in Code Snippet 4.Code Snippet 4public category SupplierService ISupplierServiceconfString =ConfigurationManager.ConnectionStrings SupplierString .ToString ( ) public Supplier GetSupplier ( int supplierId ). . .public zeroness Display ( Supplier provider ). . .The contract is be via the ISupplierService interface. The contract is implemented within the SupplierService.svc file.5.3.2 name or devouring the WCF serviceThe stairss to configure one or more service end points and host the service in an application are taken attention of by default while executing all the stairss carried out until now. For illustration, an end point is configured via the default HTTP end point set up inside the web.config file and the service is hosted by IIS and ASP.NET.Now eventually, you can name the WCF service. You need to tack a invitee to name the service. The client could be an ASP.NET Web site, a Windows application, or an application on a unalike platform.Assuming that the client is traveling to be an ASP.NET Web site for the current scenario, the stairss to name the service are as follows1. Make an ASP.NET Web site.2. To bring forth a proxy category utilizing Ocular studio apartment 2008, right-click your Web site and choice wreak Service Reference. The make for Service Reference negotiation box is displayed as shown in figure 5.2.Thi s duologue box allows you to specify an summon to your service. The construct of proxy category is similar to that in XML Web services it is a WCF service client enabling you to work with the service without holding to cover with the inside in formattingions of WCF. You can besides make the placeholder by utilizing the ServiceModel Metadata Utility command-line brute ( Svcutil.exe ) .3. Stipulate an appropriate namespace in the Namespace box in the duologue box. This namespace will specify the name for the proxy category that will be generated by Ocular Studio.4. Specify binding and end point information. Actually, the lead ServiceReference duologue box generates the appropriate end point information automatically when you add the service mention. The web.config file will incorporate this information as shown in Code Snippet 5.Code Snippet 5& lt system.serviceModel & gt & lt bindings & gt & lt wsHttpBinding & gt & lt adhering name= WSHttpBinding_ISupplierService closeTime out= 000100 openTimeout= 000100 receiveTimeout= 001000 sendTimeout= 000100 bypassProxyOnLocal= false transactionFlow= false hostNameComparisonMode= StrongWildcard maxBufferPoolSize= 524288 maxReceivedMessageSize= 65536 messageEncoding= text edition textEncoding= utf-8 use inattentionWebProxy= true allowCookies= false & gt & lt readerQuotas maxDepth= 32 maxStringContentLength= 8192 maxArrayLength= 16384 maxBytesPerRead= 4096 maxNameTableCharCount= 16384 / & gt & lt reliableSession ordered= true inactivityTimeout= 001000 enabled= false / & gt & lt security mode= Message & gt & lt transport clientCredential subject= Windows proxyCredentialType= None realm= / & gt & lt message clientCredentialType= Windows negotiateServiceCredential= true algorithmSuite= Default establishSecurityContext= true / & gt & lt /security & gt & lt /binding & gt & lt /wsHttpBinding & gt & lt /bindings & gt & lt client & gt & lt endpoint address= hyper text transfer protocol //localhost4392/SupplierService.svc binding= wsHttpBinding bindingConfiguration= WSHttpBinding_ISupplierService contract= NwServices.ISupplierService name= WSHttpBinding_ISupplierService & gt & lt individuality & gt & lt dns value= localhost / & gt & lt /identity & gt & lt /endpoint & gt & lt /client & gt & lt /system.serviceModel & gt There are two options to draw in off and redact the WCF constellation information you can redact straight in web.config or you can utilize the Service Configuration slewor to pull off your end points. Right-click the web.config file and take Edit Wcf Configuration. This will establish the Service Configuration Editor duologue box.Finally, you will make a Web page will name the service via the proxy category. Code Snippet 6 shows portion of the computer code in the Web page that will instantiate the proxy category and name the service.Code Snippet 6. . .SupplierServices.SupplierServiceClient testSupplier =new Sup plierServices.ShipperServiceClient ( ) SupplierServices.Supplier provider = new SupplierServices.Supplier ( ) provider = testSupplier.GetSupplier ( supplierCode ) 5.5 New Data Controls in ASP.NET 3.5ASP.NET 3.5 defines several new informations related discovers including LinqDataSource, EntityDataSource, and ListView.5.5.1 LinqDataSourceLanguage-Integrated interrogative sentence ( LINQ ) is a set of characteristics that adds question capablenesss to.NET lingual communications such as C . LINQ enables you to question informations from several(a) informations beginnings in an easy mode. The lone status is that these informations beginnings must be LINQ-compatible, which means they must be back up by LINQ. LINQ can be apply with SQL, XML files, objects ( such as C arrays and aggregations ) , and ADO.NET DataSets.The LinqDataSource is new to ASP.NET 3.5 and Visual Studio 2008. It is used to recover informations from a LINQ information theoretical account. This assure enables yo u to expose informations from a database by utilizing LINQ to SQL. erst you have generated informations categories utilizing the Object/Relational ( O/R ) interior decorator, you can adhere to those categories utilizing the LinqDataSource control.The ContextTypeName property is used in markup with the LinqDataSource to tie in the database context of your LINQ-based informations.See a scenario where you have defined a DataContext category named EmpDataContext utilizing Linq to SQL Classes in Visual Studio 2008. The following markup shows how you would affiliation to this category utilizing the LinqDataSource controlCode Snippet 7& lt asp LinqDataSourceID= lnqEmp runat= waiter ContextTypeName= EmpDataContext EnableDelete= True EnableInsert= True EnableUpdate= True OrderBy= EmpCode TableName= Employees & gt & lt /asp LinqDataSource & gt Alternatively of typing the markup shown in Code Snippet 7, you can besides utilize the Configure Data Source ace to tie in the DataContex t category with the LinqDataSource control. This can be done utilizing following stairss1. Add a LinqDataSource control to the Web page.2. gibe the smart ticket beside the control.3. In the context bill of fare that is displayed, choice Configure Data Source. This will expose the Configure Data Source ace as shown in figure 5.3.Figure 5.3 Configure Data Source Wizard for LinqDataSource4. Continue with the measure by measure process shown in the Configure Data Source ace.The LinqDataSource control allows you to specify parametric quantities, to bespeak sorting, enable paging, and more. You can besides specify questions holding Where and OrderBy clauses. The Where clause uses the WhereParameters stand foring a question twine that imbue outs the information on the question twine. You can besides adhere a LinqDataSource control to a data-bound control.5.5.2 EntityDataSourceThe EntityDataSource control is new to the.NET Framework 3.5. The EntityDataSource control enables you to entree informations utilizing the ADO.NET Entity Framework. Users who are familiar with data-bound controls will happen the EntityDataSource control similar to the SqlDataSource, LinqDataSource, and ObjectDataSource controls. The EntityDataSource control enables you to adhere informations in an Entity Data Model ( EDM ) to Web controls on a page. You construct questions utilizing snippings of Entity SQL codification and delegate them to the Where, OrderBy, GroupBy, and Select operators. You can provide program line values to these operations from page controls, cookies, and some other ASP.NET parametric quantity objects. The EntityDataSource interior decorator enables you to configure an EntityDataSource control easy at design clip.Similar to LinqDataSource, you can utilize the Configure Data Source ace of the EntityDataSource control to initialise the informations beginning. Figure 5.4 shows the ace.Initially, the ace enables you to choose a named connexion from the Web.Config file or add a connexion twine to link to the database. The 2nd page of the ace will hold national depending on whether a Select statement configured by the options on the ace is used or some other bid text is used.5.5.3 ListViewThe ListView control is used to adhere and expose informations points from a information beginning. The ListView provides characteristics that support folio, screening, and grouping of points. Using the ListView control, you can execute edit, insert, and delete operations on informations without the demand for any(prenominal) codification.You can adhere the ListView control to informations by utilizing the DataSourceID belongings. This enables you to adhere the ListView control to a information beginning control, such as the SqlDataSource control. You can besides adhere the ListView control to informations by utilizing the DataSource belongings. This enables you to adhere to assorted objects, which includes ADO.NET datasets and informations readers and in-memory c onstructions such as aggregations. This attack requires that you write codifications for any extra functionality such as sorting, paging, and updating.Items that are displayed by a ListView control are defined by templets, likewise to the DataList and Repeater controls. The ListView control lets you expose informations as single points or in groups.You define the chief layout of a ListView control by making a LayoutTemplate templet. The LayoutTemplate must include a control that acts as a proxy for the information. You define content for single points utilizing the ItemTemplate templet. This templet typically contains controls that are data-bound to data columns or other single informations elements.Code Snippet 8 shows a ListView control that displays names of classs from the Categories tabular array in Library database.Code Snippet 8& lt caput runat= waiter & gt & lt gentle & gt ListView Demo & lt /title & gt & lt manner type= text/css & gt .tableboundary line thin 0000 00 solid border-collapse flop boundary line 1px solid 000000 table tdboundary line 1px solid FF0000 & lt /style & gt & lt /head & gt & lt entire fertiliser structure & gt & lt signifier id= form1 runat= waiter & gt & lt div & gt & lt /div & gt & lt br / & gt & lt br / & gt & lt asp ListView runat= waiter ID= ListView1 DataSourceID= SqlDataSource1 & gt & lt LayoutTemplate & gt & lt table runat= waiter id= table1 class= tabular array & gt & lt tr runat= waiter id= itemPlaceholder & gt & lt /tr & gt & lt /table & gt & lt /LayoutTemplate & gt & lt ItemTemplate & gt & lt tr id= Tr1 runat= waiter & gt & lt td id= Td1 runat= waiter & gt & lt % Data-bound content. % & gt & lt asp pock ID= NameLabel runat= waiter Text= & lt % Eval ( Category ) % & gt / & gt & lt /td & gt & lt /tr & gt & lt /ItemTemplate & gt & lt /asp ListView & gt & lt asp SqlDataSource ID= SqlDataSource1 runat= waiter ConnectionString= & lt % $ Co nnectionStrings LibraryConnectionString % & gt SelectCommand= SELECT CategoryID , Category FROM BookCategories & gt & lt /asp SqlDataSource & gt The end growth of this markup is seen in figure 5.6.5.6 Globalization.NET Framework 4.NET Framework 3.0Ocular Studio 2005Ocular Studio.NET 2003ASP.NET allows you to develop Web applications that can be accessed by 1000000s of substance ab users crossways the Earth. This means that the Web applications should be created taking into consideration the demands of users from assorted move of the universe. Therefore, you need to internationalise your application to do it accessible to users belonging to different states, parts, civilizations, linguistic communications, and so on. Globalizationinvolves the procedure of growth Web applications that can be used by users from different parts of the universe. These Web applications will be independent of the linguistic communication and civilization.In short, globalising an application involves doing your application readable to a broad scope of users irrespective the heathen and regional differences.See a scenario of a medical research friendship in New York. The company has created a Web application that displays the resultant roles of different researches carried out by the company. The Web application is created sing a broad scope of users of different linguistic communications and civilizations. This means that the Web site is civilization and linguistic communication proper(postnominal). Therefore, for a user from United States, the Web site content appears in English and for the user from France, the Web site content appears in French, and so on. But, the company wants to follow a standard format while stand foring the medical marks and imageisms. This means that irrespective of the user s location, the marks and symbols should pure tone same. To implement this, developers can globalise the Web application.Using ASP.NET, you can make Web applications that can automatically set civilization, and arrange day of the months and currency harmonizing to user demands.ASP.NET supports globalisation by supplying the System.Globalization namespace. The System.Globalization namespace provides a set of categories to construct applications that can be supported across the Earth. These categories allow you to cover with assorted globalisation issues such as civilization, part, calendar support, and date-time data format. Table 5.1 lists the normally used categories of the System.Globalizationnamespace.ClassDescriptionCalendarThis category represents yearss in hebdomads, months, and old ages. It is the revolutionary category for other civilization specific calendars such as GregorianCalendar, JapaneseCalendar, and KoreanCalendarCultureInfoThis category provides culture-specific information such as name of the civilization and linguistic communicationNumberFormatInfoThis category represents the manner the numeral values are formatted and disp layed for a specific civilizationRegionInfoThis category provides information about country/region such as country/region name and two missive codification defined in ISO 3166Table 5.1 Normally Used Classs of System.GlobalizationFor illustration, to expose the currency symbol of the current civilization in your Web application, the codification shown in Code Snippet 9 will be used.Code Snippet 9CultureInfo curie = System.Threading.CurrentThread.CurrentCulture NumberFormatInfo nfi = ci.NumberFormat Response.Write ( Currency Symbol + nfi.CurrencySymbol + & lt BR & gt ) If the current civilization is US, the currency symbol displayed as a consequence of Code Snippet 9 will be $ .You can put the civilization or an ASP.NET Web page declaratively utilizing one of two attacksAdd a globalisation subdivision to the web.config file, and so put the uiculture and civilization properties, as shown& lt globalisation uiCulture= Es culture= es-MX / & gt This sets the UI civilization and civilization for all pages,Set the Culture and UICulture attributes of the foliate directive, as shown in the undermentioned illustration& lt % Page UICulture= Es Culture= es-MX % & gt This sets the UI civilization and civilization for an single page,.NET Framework 4Ocular Studio 2005A preference file is used to hive away user interface strings for interpreting the application into other linguistic communications. It is a utile constituent in the procedure of globalisation and localisation. Resource files are stored in XML format and contain strings, image file waies, and other alternatives. This is because you can make a separate resource file for each linguistic communication into which you want to interpret a Web page.The stairss to make a resource file are as follows control that your Web site has a booklet such as App_GlobalResources in which to hive away the resource file. You can add such a booklet by right-clicking on the Website name in declaration explorer and choosing Add ASP.NET Folder and so choosing App_GlobalResources as shown in figure 5.7.Right-click the App_GlobalResources booklet, and so snap Add New Item. This will make a resource file,In the Add New Item duologue box, under Ocular Studio installed templets, click Resource File.In the Name box, stipulate a name for the resource file and so snap Add. The Resources Editor window glass is displayed where you can type names ( keys ) , values, and optional remarks bespeaking each resource point.Type appropriate key names and values for each resource that you need in your application, and so salvage the file.To make resource files for extra linguistic communications, copy the file in Solution Explorer or in Windows Explorer, and so rename it utilizing the syntax filename.language-culture.resx. For case, if you create a planetary resource file named Resources.resx for interlingual rendition to Spanish ( Mexico ) , you will call the copied file Resources.es-mex.resx. Open the copied fil e and interpret each value, go forthing the names ( keys ) the same.Perform and reiterate stairss 6 and 7 for each extra linguistic communication that you want to utilize.5.8 accessibility Support in ASP.NET.NET Framework 4.NET Framework 3.0Ocular Studio 2005Accessible Web applications enable people with disablements to utilize helpful engineerings, such as screen readers, to work with Web pages. ASP.NET can assist you make accessible Web applications.ASP.NET controls support handiness criterions including Web Content Accessibility Guidelines 1.0 ( WCAG ) to a great extent. However, sometimes ASP.NET controls produce consequences that check to follow with all handiness criterions. In such instances, you will necessitate to manually configure the controls for handiness.You can configure keyboard support for your pages in ASP.NET utilizing one of these attacksSet check order for controls utilizing the TabIndex belongings.Stipulate a default pushing for a signifier or Panel control by puting the DefaultButton belongings.Define entree keys for button controls by puting the AccessKey belongings.Use Label controls with text boxes, which let you specify entree keys for the text boxes.5.9 industrious Applications in ASP.NET 3.5Today, in major parts of the universe, a erratic phone is no longer a luxury but a necessity. supple devices such as smartphones, Personal Digital Assistants ( PDAs ) , and others have become indispensable appliances and back up some powerful characteristics that make life easier and well-organized. These nomadic devices can hold a figure of applications installed on them. sprightly application development is hence considered to be a important portion of a developer s skillset. As an ASP.NET developer, it is imperative for you to be familiar with the creative activity of both Web and nomadic applications.5.9.1 winding Application Creation in ASP.NET 3.5In earlier versions of Ocular Studio before Visual Studio 2008, there was incorpora te interior decorator support for developing nomadic Web applications. The IDE provided an application templet utilizing which you could make a new nomadic Web application. An point templet allowed you to custom-make the show and ocular aspect of controls in Design View. Using the interior decorator, you could work with nomadic Web signifiers and nomadic Web user controls in Design View. The IDE besides provided tool chest and design-time layout support which made the undertaking of working with ASP.NET Mobile Web applications simple and easy.However, from Ocular Studio 2008 onwards, there is no reinforced -in interior decorator support for developing nomadic Web applications. You can still make and work with nomadic Web applications by utilizing downloaded templets from the Web. The stairss to make this are listed belowDownload ASP.NET Mobile Templates.zip from hypertext transfer protocol //blogs.msdn.com/b/webdevtools/archive/2007/09/17/tip-trick-asp-net- supple-development-with- visual-studio-2008.aspxExtract the nothing file. This will ensue in a figure of other nothing files.Copy the nothing files with file names stoping with _cs to My Documents Visual Studio 2008TemplatesItemTemplatesVisual C .Restart Visual Studio.Create an empty Website as shown in Figure 5.8.Select WebsiteaAdd New Item. The Add New Item duologue box will expose the freshly added templates available as shown in figure 5.9.Choose the templet Mobile Web Form as shown in figure 5.10 and click Add.A nomadic Web signifier will be added to the Website application.Switch to the codification position. You will detect that the Default category inherits from System.Web.UI.MobileControls.MobilePage.An alternate manner of making Mobile Web signifiers in Ocular Studio 2008 is to add a Web signifier to your application and so modify the page category declaration to inherit from System.Web.UI.MobileControls.MobilePage.Once the Mobile Web page is created utilizing either of these two attacks, you can so put nomadic Web controls onto the page by dragging them from the Toolbox or by typing markup and properties.Code Snippet 10 demonstrates how to make a simple nomadic signifier with a Panel and a Label control.Code Snippet 10& lt % Page Language= C AutoEventWireup= true CodeFile= Default.aspx.cs Inherits= _Default % & gt & lt % Register TagPrefix= Mobile Namespace= System.Web.UI.MobileControls Assembly= System.Web.Mobile % & gt & lt html xmlns= hypertext transfer protocol //www.w3.org/1999/xhtml & gt & lt organic structure & gt & lt nomadic Form id= Form1 runat= waiter BackColor= 99ffcc & gt & lt Mobile Label Name= lblMessage runat= waiter Font-Bold= True ForeColor= drab Font-Size= Large & gt Welcome, this is exciting & lt /mobile Label & gt & lt br & gt & lt /br & gt & lt Mobile Image ID= Image1 Runat= waiter ImageUrl= Garden.jpg & gt & lt /mobile Image & gt & lt /mobile Form & gt & lt /body & gt & lt /html & gt Save and construct the application.5.9.2 Executing Mobile ApplicationsThe stairss to ground this application are as followsInstall the Windows Mobile subterfuge Center if it is non already installed.Install Windows Mobile 6.0 sea captain SDK Refresh if it is non already installed.Select Tools- & gt Device Emulator Manager in the Visual Studio 2008 IDE.Right-click Windows Mobile 6.0 master copy Emulator in the Device Emulator Manager duologue box and choice Connect.Right-click Windows Mobile 6.0 sea captain Emulator in the Device Emulator Manager duologue box and choice Cradle. Windows Mobile Device Center ( WMDC ) is opened. Ensure that the connexion puting on WMDC is set to DMA. If you are utilizing a Work web to link to the Internet, so choose This computing machine connects to Work Network. Launch Internet Explorer on the imitator and navigate to the URL of your nomadic Web application. Assuming that the local machine name is test, the end product will be as shown in figure 5. 11. You can besides utilize the IP reference of the machine alternatively of machine name.5.9.3 Mobile Device CapabilitiesPeoples around the universe usage different nomadic devices. These devices may differ in show sizes and capablenesss. If a Web developer develops a Web application for a specific nomadic device, it may non work when exported to other nomadic devices. To get the better of this job, there is a demand of some agencies of device stressing. Device filtering is the procedure of custom-making nomadic Web waiter controls to correctly expose them on select nomadic devices.Using device filters, nomadic Web applications can custom-make the visual aspect of controls for specific hardware devices. The customization is based on the capablenesss of the hardware device being used to break the application. Device filters are used to custom-make the behaviour of Web waiter controls depending on the web browser or device that accesses them.Typically, the web.config file shops dev ice capablenesss in the & lt deviceFilters & gt subdivision.By default, your nomadic Web application in.NET Framework 3.5 and Visual Studio 2008 may non hold a web.config file. To add it, launch the Add New Item duologue box and choose the Mobile Web Configuration point templet as shown in figure 5.12.The web.config will incorporate undermentioned device filters by default in the & lt deviceFilters & gt subdivision& lt deviceFilters & gt & lt filter name= isJPhone equation= Type demarcation= J-Phone / & gt & lt filter name= isHTML32 equalise= PreferredRenderingType design= html32 / & gt & lt filter name= isWML11 compare= PreferredRenderingType assembly line= wml11 / & gt & lt filter name= isCHTML10 compare= PreferredRenderingType joust= chtml10 / & gt & lt filter name= isGoAmerica compare= Browser argument= Go.Web / & gt & lt filter name= isMME compare= Browser argument= Microsoft MobileExplorer / & gt & lt filter name= isMyPalm c ompare= Browser argument= MyPalm / & gt & lt filter name= isPocketIE compare= Browser argument= Pocket IE / & gt & lt filter name= isUP3x compare= Type argument= Phone.com 3.x Browser / & gt & lt filter name= isUP4x compare= Type argument= Phone.com 4.x Browser / & gt & lt filter name= isEricssonR380 compare= Type argument= Ericsson R380 / & gt & lt filter name= isNokia7110 compare= Type argument= Nokia 7110 / & gt & lt filter name= prefersGIF compare= PreferredImageMIME argument= image/gif / & gt & lt filter name= prefersWBMP compare= PreferredImageMIME argument= image/vnd.wap.wbmp / & gt & lt filter name= supportsColor compare= IsColor argument= true / & gt & lt filter name= supportsCookies compare= Cookies argument= true / & gt & lt filter name= supportsJavaScript compare= Javascript argument= true / & gt & lt filter name= supportsVoiceCalls compare= CanInitiateVoiceCall argument= true / & gt & lt /de viceFilters & gt ASP.NET provides the HasCapability ( ) method in the MobileCapabilities category to find device capablenesss for nomadic devices. The method takes two parametric quantities. The first is a twine stipulating a delegateName that will indicate to the device rating method, belongings name, or so forth and the 2nd parametric quantity is any value that the capabilityName statement requires. The 2nd parametric quantity is optional.The HasCapability ( ) method enables you to find through codification whether the current device lucifers any device filter stipulate in the web.config file.Code Snippet 11 shows the usage of HasCapability ( ) method.Code Snippet 11attemptbool consequence = ( ( MobileCapabilities ) Request.Browser ) .HasCapability ( supportsColor , null ) txtvwMessage.Text = answer.ToString ( ) gimmick ( ArgumentOutOfRangeException )txtvwMessage.Text = false Here, the codification tries to look into whether there is any device filter named supportsColor defin ed in the web.config file. If yes, it assigns the true value to the TextView control, txtvwMessage. If there is no such filter defined, an ArgumentOutOfRangeException is raised and a value of false is assigned to the TextView control, txtvwMessage. In the web.config file shown earlier, there is a filter named supportsColor. Therefore, the result of Code Snippet 11 is that the TextView shows true.5.9.4 Using the DeviceSpecific ControlThe procedure of rendering a control otherwise based on the browser that requested the Web page is called adaptive rendition. You use the DeviceSpecific component in ASP.NET Mobile applications to implement adaptative rendition.One or more & lt Choice & gt elements incorporating different versions of the content aiming different devices are placed inside the & lt DeviceSpecific & gt component, as shown in Code Snippet 12.Code Snippet 12& lt nomadic Form id= frmTest runat= waiter & gt & lt Mobile Label Runat= waiter ID= Label1 & gt Welcome& lt DeviceSpecific & gt & lt Choice Filter= isPocketIE Font-Italic= True Font-Name= ArialBlack / & gt & lt Choice Filter= isNokia7110 ForeColor= magenta / & gt & lt /DeviceSpecific & gt & lt /mobile Label & gt & lt /mobile Form & gt Choices are evaluated from the first & lt Choice & gt component to the last. Each clunk includes a Filter component. If the device satisfies the Filter so the content within that pick is displayed to the client. The last pick in the above illustration has no Filter. The content in this pick shows on all of the devices that forgather none of the filters.The Filter property of the & lt Choice & gt component can besides mention to a filter in the web.config file.DrumheadWCF is a incorporate scheduling theoretical account that helps to make distributed applications utilizing.NET engineerings.ASP.NET 3.5 defines several new informations related controls including LinqDataSource, EntityDataSource, and ListView.Globalization involves the pr ocedure of developing Web applications that can be used by users from different parts of the universe.A resource file is used to hive away user interface strings for interpreting the application into other linguistic communications and plays an of import function in globalisation.Most ASP.NET controls provide constitutional support for handiness in Web applications.ASP.NET 3.5 enables you to develop nomadic Web applications.Mobile device capablenesss differ from device to device and are specified utilizing & lt deviceFilters & gt in web.config file.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.