.

Saturday, December 22, 2018

'Wcf services, data access, and other features\r'

'5.1 IntroductionMicrosoft Windows conference Foundation ( WCF ) is one of the cardinal engineerings operable in.NET framework 3.0 and ulterior versions. This posing curtly introduces an overview of WCF functions. The session in both event generates a fount at the bleak informations colligate requires in ASP.NET 3.5. As organisations grow planetary, in that location is a strong demand for weather vane maskings to let in to planetary audiences and cultivations. This session describes globalization and likewise discusses the post for approachability in ASP.NET 3.5. Finally, the session explains ab egress peregrine exertions in ASP.NET 3.5.5.2 WCF dishsWCF is designed as compound programming theory-based account that helps to harbour distributed coverings utilizing assorted.NET engineerings much(prenominal) as utilizing clear runs, .NET Remoting, Message Queue ( MSMQ ) , travail parades, and so off. Through WCF, you give the gate possess a individua l att curiosity to that asshole be ambushd as physical bodyd pipes, HTTP, TCP, and so on.5.2.1 Making a WCF advantage with ASP.NETASP.NET and opthalmic studio apartment 2008 enable you to shake off and gift through WCF run. The first measure towards this is to fix the service baffle.\r\nThe stairss to specify a service take aim atomic number 18 as follows:\r\n1. Launch ocular studio apartment and choose a red-hot net labor movement of type WCF Service Application. This usher defines a nett undertaking for hosting the WCF service and pass on answer a mention to System.ServiceModel.dll in the undertaking. This assembly contains the WCF categories. The undertaking templet leave alone in any case land forth a default on on on service pertaind Service1.svc and a related contract shoot down foretelld IService1.cs. You drop re make water these cardinal rouses suitably. For exemplification, you could come up to the undertaking as TestServices and the se rvice itself as red-hotService.\r\nThe contract point, I bran-newService.cs, is a.NET Framework interf cop that includes the service property classes for the service syndicate, the operations, and the members. The.svc.cs bill is a family unit go foring this interface. A WCF Service industriousness is automatically con graded so that it digest be hosted in IIS. It introduces a hackneyed HTTP end represent. The & lt ; system.servicemodel & gt ; subdivision of the web.config file describes these scenes.\r\nAn illustration of & lt ; system.servicemodel & gt ; subdivision in web.config is shown in compute snip 1. mandate snip 1& lt ; system.serviceModel & gt ;\r\n& lt ; function & gt ;\r\n& lt ; service give ear= ” TestServices. newlyService ”\r\nbehaviorConfiguration= ” TestServices.NewService ” & gt ;\r\n& lt ; final result hook= ” ” spinal column= ” wsHttpBinding à ¢â‚¬Â\r\ncontract= ” TestServices.NewService.INewService ” & gt ;\r\n& lt ; individuality & gt ;\r\n& lt ; dns prize= ” localhost ” / & gt ;\r\n& lt ; /identity & gt ;\r\n& lt ; /endpoint & gt ;\r\n& lt ; endpoint source= ” mex ” binding= ” mexHttpBinding ” contract= ” IMeta informationExchange ” / & gt ;\r\n& lt ; /service & gt ;\r\n& lt ; /services & gt ;\r\n& lt ; demeanours & gt ;\r\n& lt ; serviceBehaviors & gt ;\r\n& lt ; behavior name= ” TestServices.NewServiceBehavior ” & gt ;\r\n& lt ; serviceMetadata httpGetEnabled= ” real ” / & gt ;\r\n& lt ; serviceDebug includeExceptionDetailInFaults= ” unreasonable ” / & gt ;\r\n& lt ; /behavior & gt ;\r\n& lt ; /serviceBehaviors & gt ;\r\n& lt ; /behaviors & gt ;\r\n& lt ; /sys tem.serviceModel & gt ;\r\n2. Implement the service contract. To tool the service, you start by specifying the contract via the interface. For illustration, blame up a scenario where you want to expose methods of a service that work with the suppliers table in a Shipments database. Make a supplier mob inside I go outrService.cs and check off it as a entropyContract and taging to apiece one of its members as DataMember. grave Snippet 2 shows an illustration: work out Snippet 2[ DataContract ]\r\n humanity mob supplier\r\n{\r\n// specify a bes\r\n[ DataMember ]\r\n semipublic int providerCode { get ; set ; }\r\n// define otherwise(a) belongingss\r\n}\r\nThe by-line measure is to specify the methods of your interface in ISupplierService.cs and tag them with the OperationContract property. You choose to tag the interface with the ServiceContract property as shown in Code Snippet 3.Code Snippet 3[ ServiceContract ]\r\npublic interface ISupplierService\r\n{\r\n[ Ope rationContract ]\r\nSupplier GetSupplier ( int supplierCode ) ;\r\n[ OperationContract ]\r\nSupplier SaveSupplier ( Supplier supplierper ) ;\r\n}\r\nWCF give employ the interface to expose a service. The service pass on be put togetherd based on the web.config file.\r\nThe service interface is implemented inside the ISupplierService.svc.cs file as shown in Code Snippet 4.Code Snippet 4public family SupplierService: ISupplierService\r\n{\r\nconfString =\r\nConfiguration four-in-hand.ConnectionStrings [ â€Å" SupplierString ” ] .ToString ( ) ;\r\npublic Supplier GetSupplier ( int supplierId )\r\n{\r\n. . .\r\n}\r\npublic nothingness Display ( Supplier provider )\r\n{\r\n. . .\r\n}\r\n}\r\nThe contract is defined via the ISupplierService interface. The contract is implemented inside the SupplierService.svc file.5.3.2 Calling or devouring the WCF serviceThe stairss to con show one or more service end points and host the service in an operation program be 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.\r\nNow eventually, you john name the WCF service. You need to put a leaf node to name the service. The client could be an ASP.NET clear site, a Windows application, or an application on a antithetic platform.\r\n take for granted that the client is traveling to be an ASP.NET weathervane site for the legitimate scenario, the stairss to name the service are as follows:\r\n1. Make an ASP.NET vane site.\r\n2. To bring forth a substitute stratum utilizing optic studio apartment 2008, right- sink in your entanglement site and pickaxe summarise Service Reference. The Add Service Reference talks package is displayed as shown in figure 5.2.\r\nThis duologue box allows you to specify an reference to your service. The re hit of substitute category is simi lar to that in XML weather vane services †it is a WCF service client enabling you to work with the service without place to cover with the inside informations of WCF. You female genitalia as well as make the place endorseer by utilizing the ServiceModel Metadata emolument command-line tool ( Svcutil.exe ) .\r\n3. Stipulate an abstract namespace in the get wordspace box in the duologue box. This namespace ordain specify the name for the proxy category that will be generated by eyepiece studio.\r\n4. Specify binding and end point information. Actually, the Add ServiceReference duologue box generates the appropriate end point information automatically when you increase the service mention. The web.config file will incorporate this information as shown in Code Snippet 5.Code Snippet 5& lt ; system.serviceModel & gt ;\r\n& lt ; bindings & gt ;\r\n& lt ; wsHttpBinding & gt ;\r\n& lt ; adhering name= ” WSHttpBinding_ISupplierService ” closeTimeout= ” 00:01:00 ”\r\nopenTimeout= ” 00:01:00 ” receiveTimeout= ” 00:10:00 ” sendTimeout= ” 00:01:00 ”\r\nbypassProxyOnLocal= ” incorrect ” transactionFlow= ” bastard ”\r\nhostNameComparisonMode= ” StrongWildcard ” maxBufferPoolSize= ” 524288 ”\r\nmaxReceivedMessageSize= ” 65536 ” messageEncoding= ” Text ”\r\n school schoolbook editionEncoding= ” utf-8 ” use default weather vaneProxy= ” reliable ” allowCookies= ” monstrous ” & gt ;\r\n& lt ; readerQuotas maxDepth= ” 32 ” maxStringContentLength= ” 8192 ”\r\nmaxArrayLength= ” 16384 ” maxBytesPerRead= ” 4096 ”\r\nmaxNameTableCharCount= ” 16384 ” / & gt ;\r\n& lt ; reliableSession ordered= ” true ” inactivityTimeout= ” 00:10:00 ”\r\nenabled= ” false â₠¬Â / & gt ;\r\n& lt ; security mode= ” Message ” & gt ;\r\n& lt ; cristal clientCredential paradigm= ” Windows ” proxyCredential graphic symbol= ” None ”\r\nrealm= ” ” / & gt ;\r\n& lt ; message clientCredentialType= ” Windows ” negotiateServiceCredential= ” true ”\r\nalgorithmSuite= ” Default ” establishSecurityContext= ” true ” / & gt ;\r\n& lt ; /security & gt ;\r\n& lt ; /binding & gt ;\r\n& lt ; /wsHttpBinding & gt ;\r\n& lt ; /bindings & gt ;\r\n& lt ; client & gt ;\r\n& lt ; endpoint address= ” hypertext conveyance of title communications protocol: //localhost:4392/SupplierService.svc ”\r\nbinding= ” wsHttpBinding ”\r\nbindingConfiguration= ” WSHttpBinding_ISupplierService ”\r\ncontract= ” NwServices.ISupplierService ”\r\nname= ” WSHttpB inding_ISupplierService ” & gt ;\r\n& lt ; individuality & gt ;\r\n& lt ; dns value= ” localhost ” / & gt ;\r\n& lt ; /identity & gt ;\r\n& lt ; /endpoint & gt ;\r\n& lt ; /client & gt ;\r\n& lt ; /system.serviceModel & gt ;\r\nThere are both options to shoot down off and redact the WCF configuration information: you substructure redact straight off in web.config or you coffin nail implement 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.\r\nFinally, you will make a weathervane scalawag will name the service via the proxy category. Code Snippet 6 shows dish out of the computer code in the Web paginate that will instantiate the proxy category and name the service.Code Snippet 6. . .\r\nSupplierServices.SupplierServiceClient testSupplier =\r\nnew SupplierServices.ShipperServiceClient ( ) ;\r\nSupplierServices.Supplier provider = new SupplierServices.Supplier ( ) ;\r\nprovider = testSupplier.GetSupplier ( supplierCode ) ;5.5 New Data Controls in ASP.NET 3.5ASP.NET 3.5 defines several new informations related tells including LinqData point of reference, EntityData quotation, and ListView.5.5.1 LinqData ascendent delivery-Integrated Query ( LINQ ) is a set of characteristics that adds scruple capablenesss to.NET lingual communication theory much(prenominal) as C # . LINQ enables you to question informations from diverse informations founts in an delicate mode. The lone status is that these informations beginnings essential(prenominal) be LINQ-compatible, which sum they must be gageed by LINQ. LINQ potful be use with SQL, XML files, objects ( such(prenominal)(prenominal) as C # swans and aggregations ) , and ADO.NET Data garnishs.\r\nThe LinqDataSource is new to ASP.NET 3.5 and ocular studio 2008. It is used to r ecover informations from a LINQ information conjectural account. This rule enables you to expose informations from a database by utilizing LINQ to SQL. Once you have generated informations categories utilizing the Object/relational ( O/R ) inside decorator, you can truss to those categories utilizing the LinqDataSource controller.\r\nThe ContextTypeName property is used in markup with the LinqDataSource to tie in the database context of your LINQ-based informations.\r\n search 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 control:Code Snippet 7& lt ; asp viper: LinqDataSource\r\nID= ” lnqEmp ”\r\nrunat= ” waiter ”\r\nContextTypeName= ” EmpDataContext ”\r\nEnableDelete= ” aline ”\r\nEnableInsert= ” True ”\r\nEnableUpdate= ” True â⠂¬Â\r\nOrderBy= ” EmpCode ”\r\nTableName= ” Employees ” & gt ;\r\n& lt ; /asp: LinqDataSource & gt ;\r\nAlternatively of typing the markup shown in Code Snippet 7, you can alike utilize the put together Data Source ace to tie in the DataContext category with the LinqDataSource control. This can be done utilizing following stairss:\r\n1. Add a LinqDataSource control to the Web summon.\r\n2. Snap the smart ticket beside the control.\r\n3. In the context bill of fare that is displayed, plectron Configure Data Source. This will expose the Configure Data Source ace as shown in figure 5.3. mannequin 5.3: Configure Data Source Wizard for LinqDataSource4. conduct with the measure by measure process shown in the Configure Data Source ace.\r\nThe LinqDataSource control allows you to specify parametric quantities, to presage 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 drift that penetrates the information on the question twine. You can besides bind 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 access code informations utilizing the ADO.NET Entity Framework. Users who are long-familiar with data-bound controls will guide the EntityDataSource control similar to the SqlDataSource, LinqDataSource, and ObjectDataSource controls. The EntityDataSource control enables you to truss informations in an Entity Data Model ( EDM ) to Web controls on a pageboy. You construct questions utilizing snippings of Entity SQL codification and delegate them to the Where, OrderBy, GroupBy, and postulate operators. You can provide parameter set to these operations from page controls, cookies, and other ASP.NET parametric sum objects. The EntityDataSource inner decorator enables you to con figure an EntityDataSource control easy at design clip.\r\nSimilar 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.\r\nInitially, the ace enables you to choose a named connecter from the Web.Config file or add a connexion twine to link to the database. The second page of the ace will hold heart depending on whether a Select statement configured by the options on the ace is used or just about other bid text is used.5.5.3 ListViewThe ListView control is used to stick to and expose informations points from a information beginning. The ListView provides characteristics that survive folio, intering, and grouping of points. apply the ListView control, you can execute edit, insert, and delete operations on informations without the demand for any codification.\r\nYou can adhere the ListView control to informations by utilizing the DataSourceID belongings. This enables y ou 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 constructions such as aggregations. This besiege requires that you write codifications for any extra functionality such as sorting, paging, and updating.\r\n souvenirs 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 unmarried points or in groups.\r\nYou define the chief layout of a ListView control by qualification a LayoutTemplate templet. The LayoutTemplate must include a control that acts as a proxy for the information. You define mental ability for single points utilizing the ItemTemplate templet. This templet typically contains controls th at are data-bound to data columns or other single informations elements.\r\nCode 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 ;\r\n& lt ; title & gt ; ListView depict & lt ; /title & gt ;\r\n& lt ; manner type= ” text/css ” & gt ;\r\n.table\r\n{\r\nboundary line: thin # 000000 square(a) ;\r\nborder-collapse: prostration ;\r\nboundary line: 1px loyal # 000000 ;\r\n}\r\ntable td\r\n{\r\nboundary line: 1px potent # FF0000 ;\r\n}\r\n& lt ; /style & gt ;\r\n& lt ; /head & gt ;\r\n& lt ; organic social system & gt ;\r\n& lt ; kind id= ” form1 ” runat= ” waiter ” & gt ;\r\n& lt ; div & gt ;\r\n& lt ; /div & gt ;\r\n& lt ; br / & gt ;\r\n& lt ; br / & gt ;\r\n& lt ; asp: ListView runat= † waiter ” ID= ” ListView1 ” DataSourceID= ” SqlDataSource1 ” & gt ;\r\n& lt ; LayoutTemplate & gt ;\r\n& lt ; table runat= ” waiter ” id= ” table1 ” class= ” tabular array ” & gt ;\r\n& lt ; tr runat= ” waiter ” id= ” itemPlaceholder ” & gt ;\r\n& lt ; /tr & gt ;\r\n& lt ; /table & gt ;\r\n& lt ; /LayoutTemplate & gt ;\r\n& lt ; ItemTemplate & gt ;\r\n& lt ; tr id= ” Tr1 ” runat= ” waiter ” & gt ;\r\n& lt ; td id= ” Td1 ” runat= ” waiter ” & gt ;\r\n& lt ; % — Data-bound content. — % & gt ;\r\n& lt ; asp: scar ID= ” Name distinguish ” runat= ” waiter ” Text= ‘ & lt ; % # Eval ( â€Å" family ” ) % & gt ; ‘ / & gt ;\r\n& lt ; /td & gt ;\r\n& lt ; /tr � 38; gt ;\r\n& lt ; /ItemTemplate & gt ;\r\n& lt ; /asp: ListView & gt ;\r\n& lt ; asp: SqlDataSource ID= ” SqlDataSource1 ” runat= ” waiter ” ConnectionString= ” & lt ; % $ ConnectionStrings: LibraryConnectionString % & gt ; ”\r\nSelectCommand= ” rent [ CategoryID ] , [ Category ] FROM [ BookCategories ] ” & gt ; & lt ; /asp: SqlDataSource & gt ;\r\nThe end mathematical product of this markup is seen in figure 5.6.\r\n5.6 Globalization.NET Framework 4.NET Framework 3.0 visual Studio 2005Ocular Studio.NET 2003ASP.NET allows you to develop Web applications that can be accessed by 1000000s of drug users crosswise the Earth. This means that the Web applications should be created taking into esteem the demands of users from assorted split of the universe. Therefore, you need to internationalize your application to do it accessible to users belonging to distinct states, separate, acc ulturations, linguistic communications, and so on. Globalizationinvolves the effect of developing Web applications that can be used by users from different parts of the universe. These Web applications will be self-employed person of the linguistic communication and culture.\r\nIn short, globalising an application involves doing your application readable to a roomy scope of users irrespective the cultural and functional differences.\r\nSee a scenario of a health check examination research company 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 liberal 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 a ppears in French, and so on. But, the company wants to follow a criterion format while stand foring the medical marks 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.\r\n use ASP.NET, you can make Web applications that can automatically set civilization, and arrange daylight of the months and currency harmonizing to user demands.\r\nASP.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 basal 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 communicationNumber variationatInfoThis category represents the manner 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 use Classs of System.GlobalizationFor illustration, to expose the currency symbol of the authentic civilization in your Web application, the codification shown in Code Snippet 9 will be used.Code Snippet 9CultureInfo curie = System.Threading.CurrentThread.CurrentCulture ;\r\nNumber formulateatInfo nfi = ci.NumberFormat ;\r\nResponse.Write ( â€Å" Currency Symbol: â€Å" + nfi.CurrencySymbol + â€Å" & lt ; BR & gt ; ” ) ;\r\nI f the watercourse civilization is US, the currency symbol displayed as a consequence of Code Snippet 9 will be $ .\r\nYou can put the civilization or an ASP.NET Web page declaratively utilizing one of two attacks:Add 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 ;\r\nThis sets the UI civilization and civilization for all pages,Set the Culture and UICulture attributes of the @ varlet directive, as shown in the undermentioned illustration:& lt ; % @ Page UICulture= ” Es ” Culture= ” es-MX ” % & gt ;\r\nThis sets the UI civilization and civilization for an single page,.NET Framework 4Ocular Studio 2005A imagery file is used to hive away past user interface set up for construe the application into other linguistic communications. It is a utile constituent in the operation of global isation and localisation. Resource files are stored in XML format and contain strings, image file waies, and other mental imagerys. This is because you can make a separate resource file for each linguistic communication into which you want to constitute a Web page.\r\nThe stairss to make a resource file are as follows:Ensure that your Web site has a cusp 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 termination venturer and choosing Add ASP.NET booklet 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 sparkler is displayed where you can type names ( come upons ) , values, and facultat ive remarks bespeaking each resource point.Type appropriate key names and values for each resource that you need in your application, and so spare 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 version to Spanish ( Mexico ) , you will call the copied file Resources.es-mex.resx. Open 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 have a bun in the oven in ASP.NET.NET Framework 4.NET Framework 3.0Ocular Studio 2005Accessible Web applications enable people with disablements to utilize careive engineerings, such as screen readers, to work with Web pages. ASP.NET can assist you make accessible Web applications.\r\nASP.NET controls support handiness criterions including Web Content Accessibility Guidelines 1.0 ( WCAG ) to a great extent. However, sometimes ASP.NET controls say consequences that fail to follow with all handiness criterions. In such instances, you will take away to manually configure the controls for handiness.\r\nYou can configure keyboard support for your pages in ASP.NET utilizing one of these attacks:Set check order for controls utilizing the TabIndex belongings.Stipulate a default button for a signifier or Panel control by puting the DefaultButton belongings.Define entrance money 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 agile Applications in ASP.NET 3.5Today, in study parts of the universe, a wandering phone is no longer a opulence but a necessity. rambling contrivances such as smartphones, Personal Digital Assistants ( PDAs ) , and other s have become indispensable appliances and back up many powerful characteristics that make support easier and well-organized. These winding dodges can hold a figure of applications installed on them. wandering 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 winding applications.5.9.1 meandering(a) Application cosmea in ASP.NET 3.5In earlier versions of Ocular Studio before Visual Studio 2008, thither was built-in inner 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 tailor-make the show and visual shot of controls in stick out View. Using the interior decorator, you could work with nomadic Web signifiers and nomadic Web user controls in Design View. The IDE besides prov ided tool chest and design-time layout support which made the undertaking of working with ASP.NET brisk Web applications simple and easy.\r\nHowever, 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 below:download ASP.NET wandering(a) 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 ad ded templates available as shown in figure 5.9.Choose the templet runny Web Form as shown in figure 5.10 and click Add.A nomadic Web signifier will be added to the Website application.\r\n confound to the codification position. You will detect that the Default category gets 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 measure up 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 ;\r\n& lt ; % @ Register TagPrefix= ” Mobile ” Namespace= ” System.Web.UI.MobileControls ” Assembly= ” System.Web.Mobile ” % & gt ;\r\n& lt ; html xmlns= ” hypertext transfer protocol: //www.w3.org/1999/xhtml ” & gt ;\r\n& lt ; organic structure & gt ;\r\n& lt ; nomadic: Form id= ” Form1 ” runat= ” waiter ” BackColor= ” # 99ffcc ” & gt ;\r\n& lt ; Mobile: Label Name= ” lblMessage ” runat= ” waiter ” Font-Bold= ” True ” ForeColor= ” Blue ”\r\nFont-Size= ” medium-large ” & gt ; Welcome, this is exciting & lt ; /mobile: Label & gt ;\r\n& lt ; br & gt ; & lt ; /br & gt ;\r\n& lt ; Mobile: Image ID= ” Image1 ” Runat= ” waiter ” ImageUrl= ” Garden.jpg ” & gt ;\r\n& lt ; /mobile: Image & gt ;\r\n& lt ; /mobile: Form & gt ;\r\n& lt ; /body & gt ;\r\n& lt ; /html & gt ;\r\nSave and construct the application.5.9.2 Executing Mobile ApplicationsThe stairss to prove this application are as follows:Install the Windows Mobile crook center if it is non already installed.Install Windows Mobile 6.0 Professional SDK Refresh if it is non already installed.Select Tools- & gt ; stratagem emulator Manager in the Visual Studio 2008 IDE.Right-click Windows Mobile 6.0 Professional Emulator in the dodge Emulator Manager duologue box and choice Connect.Right-click Windows Mobile 6.0 Professional Emulator in the thingmabob 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 network, so choose â€Å" This cipher gondola connects to Work Network. ”Launch Internet Explorer on the c opycat and journey 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 thingmabobs. These widgets may differ in show sizes and capablenesss. If a Web developer develops a Web application for a specific nomadic art, it may non work when exported to other nomadic constructions. To get the better of this job, there is a demand of some agencies of whatchamacallum tenseing. Device trickleing is the mapping of custom-making nomadic Web waiter controls to correctly expose them on select nomadic devices.\r\nUsing device filtrates, 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 shop the appli cation. Device filters are used to custom-make the behaviour of Web waiter controls depending on the browser or device that accesses them.\r\nTypically, the web.config file shops device capablenesss in the & lt ; device reachs & gt ; subdivision.\r\nBy 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.\r\nThe web.config will incorporate undermentioned device filters by default in the & lt ; device slobbers & gt ; subdivision:\r\n& lt ; deviceFilters & gt ;\r\n& lt ; filter name= ” isJPhone ” equal= ” Type ” subscriber line= ” J-Phone ” / & gt ;\r\n& lt ; filter name= ” isHTML32 ” analyze= ” PreferredRenderingType ”\r\n sway= ” html32 ” / & gt ;\r\n& lt ; filter name= ” isWML11 ” examine= ” PreferredRenderingType ” credit line= ” wml11 ”\r\n/ & gt ;\r\n& lt ; filter name= ” isCHTML10 ” study= ” PreferredRenderingType ”\r\n strain= ” chtml10 ” / & gt ;\r\n& lt ; filter name= ” isGoAmerica ” compare= ” web browser ” line= ” Go.Web ” / & gt ;\r\n& lt ; filter name= ” isMME ” compare= ” web browser ” argument= ” Microsoft Mobile\r\nExplorer ” / & gt ;\r\n& lt ; filter name= ” isMyPalm ” compare= ” browser ” argument= ” MyPalm ” / & gt ;\r\n& lt ; filter name= ” isPocketIE ” compare= ” Browser ” argument= ” Pocket IE ” / & gt ;\r\n& lt ; filter name= ” isUP3x ” compare= ” Type ” argument= ” Phone.com 3.x Browser ” / & gt ;\r\n& lt ; filter name= ” isUP4x ” compare= ” Type ” argument= ” Phone.com 4.x Browser ” / & gt ;\r\n& lt ; filter name= ” isEricssonR380 ” compare= ” Type ” argument= ” Ericsson R380 ” / & gt ;\r\n& lt ; filter name= ” isNokia7110 ” compare= ” Type ” argument= ” Nokia 7110 ” / & gt ;\r\n& lt ; filter name= ” prefersGIF ” compare= ” PreferredImageMIME ”\r\nargument= ” image/gif ” / & gt ;\r\n& lt ; filter name= ” prefersWBMP ” compare= ” PreferredImageMIME ”\r\nargument= ” image/vnd.wap.wbmp ” / & gt ;\r\n& lt ; filter name= ” supportsColor ” compare= ” IsColor ” argument= ” true ” / & gt ;\r\n& lt ; filter name= ” supportsCookies ” compare= ” Cookies ” argument= ” true ” / & gt ;\r\n& lt ; filter name= ” supportsJavaScript ” compare= ” Javascript ” argument= ” true ” / & gt ;\r\n& lt ; filter name= ” supportsVoiceCalls ” compare= ” CanInitiateVoiceCall ” argument= ” true ” / & gt ;\r\n& lt ; /deviceFilters & gt ;\r\nASP.NET provides the HasCapability ( ) method in the MobileCapabilities category to have 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 second parametric quantity is any value that the capabilityName statement requires. The 2nd parametric quantity is optional.\r\nThe HasCapability ( ) method enables you to note through codification whether the current device lucifers any device filter contract in the web.config file.\r\nCode Snippet 11 shows the usage of HasCapability ( ) m ethod.Code Snippet 11:attempt\r\n{\r\nbool consequence = ( ( MobileCapabilities ) Request.Browser ) .HasCapability ( â€Å" supportsColor ” , null ) ;\r\ntxtvwMessage.Text = answer.ToString ( ) ;\r\n}\r\ngimmick ( ArgumentOutOfRangeException )\r\n{\r\ntxtvwMessage.Text = â€Å" false ” ;\r\n}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 otherwise based on the browser that requested the Web page is called adaptative rendition. You use the DeviceSpeci fic component part in ASP.NET Mobile applications to implement adaptative rendition.\r\n bingle or more & lt ; excerption & gt ; elements incorporating different versions of the content aiming different devices are set(p) inside the & lt ; DeviceSpecific & gt ; component, as shown in Code Snippet 12.Code Snippet 12& lt ; nomadic: Form id= ” frmTest ” runat= ” waiter ” & gt ;\r\n& lt ; Mobile: Label Runat= ” waiter ” ID= ” Label1 ” & gt ;\r\nWelcome\r\n& lt ; DeviceSpecific & gt ;\r\n& lt ; Choice Filter= ” isPocketIE ” Font-Italic= ” True ” Font-Name= ” Arial\r\nBlack ” / & gt ;\r\n& lt ; Choice Filter= ” isNokia7110 ” ForeColor= ” Magenta ” / & gt ;\r\n& lt ; /DeviceSpecific & gt ;\r\n& lt ; /mobile: Label & gt ;\r\n& lt ; /mobile: Form & gt ;\r\nChoices are evaluated from th e first & lt ; Choice & gt ; component to the close. Each pick 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 satisfy none of the filters.\r\nThe 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 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 impo rt 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.\r\n'

No comments:

Post a Comment

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