пятница, 22 февраля 2019 г.

Wcf services, data access, and other features

5.1 IntroductionMicrosoft Windows Communication Foundation ( WCF ) is cardinalness of the cardinal engineerings available in.NET Frame run for 3.0 and ulterior versions. This posing briefly introduces an overview of WCF religious processs. The session in all event takes a expression at the modern nurtures associate admits in ASP.NET 3.5. As organisations grow planetary, there is a strong demand for mesh fiddle coats to accommodate to planetary audiences and polishs. This session describes globalisation and besides discusses the sustentation for approachability in ASP.NET 3.5. Finally, the session explains about roving applications in ASP.NET 3.5.5.2 WCF ServicesWCF is designed as incorporate programming theoretical account that helps to work distributed applications utilizing assorted.NET engineerings much(prenominal)(prenominal) as utilizing vane renovations, .NET Remoting, Message Queue ( MSMQ ) , Enterprise Services, and so forth. Through WCF, you git make a individual service that freighter be unresolved as shoutd pipes, HTTP, TCP, and so on.5.2.1 Making a WCF Service with ASP.NETASP.NET and ocular studio apartment 2008 change you to make and devour WCF services. The inaugural measure towards this is to local anestheticize the service compact.The stairss to characterise a service stuff ar as follows1. drive Ocular studio apartment and aim a new blade mark about of type WCF Service Application. This templet defines a meshing chore for hosting the WCF service and leave make a mention to System.ServiceModel.dll in the chthoniantaking. This assembly tallys the WCF categories. The undertaking templet will besides bring forth a neglect service physiqued Service1.svc and a related contract single file get upd IService1.cs. You foot name these two files suitably. For illustration, you could call the undertaking as TestServices and the service itself as NewService.The contract file, INewService.cs, is a.NET Framewor k porthole that implys the service station classes for the service family, the operations, and the members. The.svc.cs file is a category implementing this interface. A WCF Service application is mechanically con cons trued so that it send packing be hosted in IIS. It publishs a bagard HTTP block off point. The & lt system.servicemodel & gt fraction of the web.config file describes these scenes.An illustration of & lt system.servicemodel & gt subdivision in web.config is manifestn in jurisprudence snip 1.Code snipping 1& lt system.serviceModel & gt & lt services & gt & lt service name= TestServices.NewService behavior conformity= TestServices.NewService & gt & lt expiry apostrophize= book binding= wsHttpBinding contract= TestServices.NewService.INewService & gt & lt individuality & gt & lt dns value= localhost / & gt & lt /identity & gt & lt /endpoint & gt & lt endpoint bring inress= 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= true / & 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 suck in by fastening the contract via the interface. For illustration, see a scenario where you want to light upon methods of a service that work with the Suppliers table in a Shipments database. Make a Supplier category inside ISupplierService.cs and tag it as a DataContract and taging each(prenominal) of its members as DataMember. Code snippet 2 enters an illustrationCode clipping 2 DataContract semi worldly concern category Supplier// specify a belongings DataMember public int SupplierCode get tidy sum // define different belongi ngssThe following measure is to specify the methods of your interface in ISupplierService.cs and tag them with the OperationContract property. You take aim to tag the interface with the ServiceContract property as shown in Code clipping 3.Code snippet 3 ServiceContract public interface ISupplierService OperationContract Supplier GetSupplier ( int supplierCode ) OperationContract Supplier bearSupplier ( Supplier supplierper ) WCF will utilize the interface to expose a service. The service will be con contrived based on the web.config file.The service interface is implemented inside 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 nothingness Display ( Supplier leadr ). . .The contract is defined via the ISupplierService interface. The contract is implemented inside t he SupplierService.svc file.5.3.2 Calling or devouring the WCF serviceThe stairss to con come in one or more service end points and host the service in an application be taken attention of by inattention succession executing all the stairss carried out until now. For illustration, an end point is con simulacrumd via the default option HTTP end point set up inside the web.config file and the service is hosted by IIS and ASP.NET.Now eventually, you puke name the WCF service. You extremity to put a client to name the service. The client could be an ASP.NET Web site, a Windows application, or an application on a different platform.Assuming that the client is travel to be an ASP.NET Web site for the certain scenario, the stairss to name the service be as follows1. Make an ASP.NET Web site.2. To bring forth a deputy category utilizing Ocular Studio 2008, right-click your Web site and election increase Service Reference. The annex Service Reference dialogue misfortune is d isplayed as shown in figure 5.2.This duologue box seat allows you to specify an graphic symbol to your service. The puddle 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 go with the inside infos of WCF. You advise besides make the placeholder by utilizing the ServiceModel Metadata utility program command- seam tool ( 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 data. Actually, the Add ServiceReference duologue box generates the appropriate end point schooling automatically when you correspond 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 na me= WSHttpBinding_ISupplierService closeTimeout= 000100 openTimeout= 000100 receiveTimeout= 001000 sendTimeout= 000100 bypassProxyOnLocal= false transactionFlow= false hostNameComparisonMode= StrongWildcard maxBufferPoolSize= 524288 maxReceivedMessageSize= 65536 messageEncoding= school text text editionEncoding= utf-8 useDefaultWebProxy= true allowCookies= false & gt & lt readerQuotas maxDepth= 32 maxStringContentLength= 8192 maxArrayLength= 16384 maxBytesPerRead= 4096 maxName submitCharCount= 16384 / & gt & lt reliableSession ordered= true inactivityTimeout= 001000 enabled= false / & gt & lt bail mode= Message & gt & lt move clientCredential suit= 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= hypertext expatriation 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 pull off and redact the WCF shape information you can redact straight in web.config or you can utilize the Service Configuration Editor 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 rogue will name the service via the proxy category. Code Snippet 6 shows portion of the codification in the Web rascal that will represent the proxy category and name the service.Code Snippet 6. . .SupplierServices.Suppli erServiceClient testSupplier =new SupplierServices.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 some(prenominal) new informations related manoeuvers including LinqDataSource, EntityDataSource, and ListView.5.5.1 LinqDataSource verbiage-Integrated Query ( LINQ ) is a set of characteristics that adds question capablenesss to.NET lingual intercourses such as C . LINQ enables you to question informations from diverse informations beginnings in an easy mode. The lonely(prenominal) status is that these informations beginnings must be LINQ-compatible, which office 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 utilize to re give chase informations from a LINQ in formation theoretical account. This find out enables you to expose informations from a database by utilizing LINQ to SQL. Once you work generated informations categories utilizing the Object/Relational ( O/R ) interior designer, you can bond to those categories utilizing the LinqDataSource fancy.The ContextTypeName property is employ in markup with the LinqDataSource to tie in the database lingual context of your LINQ-based informations. bet 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 link to this category utilizing the LinqDataSource controlCode Snippet 7& lt asp viper viper LinqDataSourceID= lnqEmp runat= server 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 ca n besides utilize the Configure Data Source ace to tie in the DataContext category with the LinqDataSource control. This can be done utilizing following stairss1. Add a LinqDataSource control to the Web scallywag.2. Snap 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 tenses the information on the question twine. You can besides lodge a LinqDataSource control to a data-bound control.5.5.2 EntityDataSourceThe EntityDataSource control is new to t he.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 bring together informations in an Entity Data Model ( EDM ) to Web controls on a rapscallion. You do questions utilizing snippings of Entity SQL codification and delegate them to the Where, OrderBy, GroupBy, and give operators. You can provide parameter set to these operations from page controls, cookies, and other ASP.NET parametric amount of money 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 initialize the informations beginning. Figure 5.4 shows the ace.Initiall y, 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 capacity 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 alimentation 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 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, wh ich includes ADO.NET datasets and informations readers and in-memory constructions such as aggregations. This attack requires that you spare 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 nous 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 brainpowerway runat= host & gt & lt title & gt ListView Demo & lt /title & gt & lt appearance type= text/css & gt .tableboundary line thin 000000 solid border-collapse prostration boundary line 1px solid 000000 table tdboundary line 1px solid FF0000 & lt /style & gt & lt /head & gt & lt organic 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 Label 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 Sql DataSource ID= SqlDataSource1 runat= waiter ConnectionString= & lt % $ ConnectionStrings LibraryConnectionString % & gt SelectCommand= SELECT CategoryID , Category FROM BookCategories & gt & lt /asp SqlDataSource & gt The end product 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 users across the Earth. This means that the Web applications should be created taking into consideration the demands of users from assorted split of the introduction. Therefore, you need to internationalise your application to do it accessible to users belonging to different states, parts, civilizations, lingual communications, and so on. Globalizationinvolves the single-valued function of developing Web applications that can be used by users from different parts of the universe. These Web applications will be strong-minded of the linguistic communication and civilization.In short, globalising an application involves doing your application readable to a broad scope of users irrespective the cultural and countryal differences.See a scenario of a medical research fraternity in New York. The company has created a Web application that displays the consequences 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 specialised. 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 tag and symbols. This means that irrespective of the user s location, the marks and symbols should look 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 daytime of the months and currency harmonizing to user demands.ASP.NET nourishments 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 basal category for other civilization specific calendars such as GregorianCalendar, JapaneseCalendar, and KoreanCalendar finaleInfoThis category provides culture-specific information such as name of the civilization and linguistic communicationNumberFormatInfoThis categor y represents the look the numeral values are formatted and displayed 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 imagination file is used to hive away user interface strings for translation 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 resources. This is because you can make a know apart resource file for each linguistic communication into which you want to visualise a Web page.The stairss to make a resource file are as followsEnsure 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 ri ght-clicking on the Website name in Solution 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. pass the copied file 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 availableness Support in ASP.NET.NET Framework 4.NET Framework 3.0Ocular Studio 2005Accessible Web applications enable people with disablements to utilize assistive 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 fail 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.Sti pulate a default button 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 runny Applications in ASP.NET 3.5Today, in major parts of the universe, a nomadic phone is no longer a lavishness but a necessity. fluent pulls such as smartphones, Personal digital Assistants ( PDAs ) , and others have become indispensable appliances and back up many fibrous characteristics that make life easier and well-organized. These nomadic twirls can hold a figure of applications installed on them. Mobile 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 Mobile Application Creation in ASP.NET 3.5In earlier versions of Ocular Studio to begin with Visual Studio 2008, there was built-in 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 customize the show and visual aspect of controls in form 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 running(a) 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/200 7/09/17/tip-trick-asp-net-mobile-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. riff 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 c reated 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= Blue Font-Size= Large & gt Welcome, this is kindle & 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 F orm & gt & lt /body & gt & lt /html & gt Save and construct the application.5.9.2 Executing Mobile ApplicationsThe stairss to prove this application are as followsInstall the Windows Mobile Device Center if it is non already installed.Install Windows Mobile 6.0 passe-partout SDK Refresh if it is non already installed.Select Tools- & gt Device aper Manager in the Visual Studio 2008 IDE.Right-click Windows Mobile 6.0 Professional aper in the Device Emulator Manager duologue box and choice Connect.Right-click Windows Mobile 6.0 Professional 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 copycat and navigate to the URL of your nomadic Web application. Assuming that the local machine name is test, the end pr oduct 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 let out of this job, there is a demand of some agencies of device straining. Device riddleing is the procedure of custom-making nomadic Web waiter controls to correctly expose them on charter nomadic devices.Using device filters, nomadic Web applications can custom-make the visual aspect of controls for specific computer hardware devices. The customization is based on the capablenesss of the hardware device being used to shop the application. Device filters are used to custom-make the behaviour of Web waiter controls depending on the browser or device that accesses th em.Typically, the web.config file shops device capablenesss in the & lt devicesifts & 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 discriminate= Type line= J-Phone / & gt & lt filter name= isHTML32 equality= PreferredRenderingType statement= html32 / & gt & lt filter name= isWML11 liken= PreferredRenderingType leaning= wml11 / & gt & lt filter name= isCHTML10 compare= PreferredRenderingType argument= chtml10 / & gt & lt filter name= isGoAmerica compare= web browser argument= Go.Web / & gt & lt filter name= isMME compare= Browser argument= Microsoft MobileExplorer / & gt & lt filter name= isMyPalm compare= 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= CanInitiateVoice Call argument= true / & gt & lt /deviceFilters & 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 undertake 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 ( ) widget ( ArgumentOutOfRangeException )txtvwMessage.Text = false Here, the codification tries to look into whether there is any device filter named supportsColor defined 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 differently based on the browser that requested the Web page is called adaptational rendition. You use the DeviceSpecific component in ASP.NET Mobile applications to implement adaptative rendition. iodine or more & lt selection & 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 M obile 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 filling includes a Filter component. If the device satisfies the Filter so the content within that cream 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 satisfy 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, Enti tyDataSource, and ListView.Globalization involves the procedure 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.

Комментариев нет:

Отправить комментарий