15 € La Documentation française Auteur(s) : PIERRE LE GUERINEL Collection : Formation Administration Concours (FAC)... lire la suite
La justice administrative va connaitre aussi sa reforme.
Product Listing By Category Users will be able to see a listing of all products within a particular product category by navigating to the /Products/Category/[CategoryID] URL: Users will be able to add a new product to the store by clicking the "Add New Product" link above. This takes them to the /Products/New URL - where they will be prompted to enter details about a new product to add: When they hit save, the product will be added to the database, and they will be redirected back to the product listing page. We'll begin by right-clicking on our /Models sub-folder in our ASP.NET MVC project, and select "Add New Item" -> "LINQ to SQL Classes" to bring up the LINQ to SQL ORM designer and model our data objects: Our ProductsController class will handle URLs like /Products/Category/3, /Products/New, and /Products/Edit/5 by implementing "Category", "New", and "Edit" actions: Our Controller actions will be using three View pages in order to render output. The "List.aspx", "New.aspx", and "Edit.aspx" pages will live under the \Views\Products sub-folder, and be based on the Site.Master master page under \Views\Shared. Implementing Product Listing By Category The first part of the site that we'll implement will be the Product Listing URL (/Products/Category/[CategoryId]): We'll implement this functionality using the "Category" action on our ProductsController class. We'll use our LINQ to SQL DataContext class, and the GetCategoryById helper method we added to it, to retrieve a Category object that represents the particular category indicated by the URL (for example: /Products/Category/3). We'll then pass the Category object to the "List" view to render a response from it: When implementing our List view we'll first update our page's code-behind to derive from ViewPage so that our page's ViewData property will be typed to the Category object that was passed by our Controller (Part 3 discusses this more): Form input and editing scenarios are typically handled in the ASP.NET MVC Framework by exposing two Action methods on a Controller class. The first Controller Action method is responsible for sending down the HTML containing the initial form to display. The second Controller action method is then responsible for handling any form submissions sent back from the browser. For example, for our "Add Product" screen above we could choose to implement it across two different ProductsController actions: one called "New" and one called "Create". The /Products/New URL would be responsible for displaying an empty form with HTML textboxes and drop-down list controls to enter new product details. The HTML element on this page would then have its "action" attribute set to the /Products/Create URL. This means that when the user presses a form submit button on it, the form inputs will be sent to the "Create" action to process and update the database with. The HTML form sent to the client is implemented in the "New.aspx" view called by the "New" action method. An initial implementation of this (using textboxes for everything) would look like below: Note above how we are using a standard HTML element on the page (not a form runat=server). The form's "action" attribute is set to post to our "Create" action method on ProductsController. The post will happen when the element at the bottom is pressed. When this happens, the ASP.NET MVC Framework will automatically handle mapping the ProductName, CategoryID, SupplierID and UnitPrice values as method parameters to the "Create" action method on ProductsController: The product entry screen we created in the previous section works, but isn't very user friendly. Specifically, it requires that the end user know the raw CategoryID and SupplierID numbers for the Product being entered. We need to fix this by instead displaying an HTML dropdownlist that displays the human readable names. Our first step will be to modify our ProductsController to pass to the View two collections - one containing a list of available categories, the other a list of available suppliers. We'll do this by creating a strongly typed ProductsNewViewData class that encapsulates these, and which we'll then pass to the View (you can learn about this in Part 3): One approach we could use to generate our dropdowns would be to manually create our own for-loop containing if/else statements within the HTML. This would give us total control over the HTML - but would make the HTML messy. The HtmlHelper object (as well as the AjaxHelper object - which we'll talk about in a later tutorial) have been specifically designed to be easily extended using "Extension Methods" - which is a new language feature of VB and C# in the VS 2008 release. What this means is that anyone can create their own custom helper methods for these objects and share them for you to use. Note: because we are still posting a CategoryID and SupplierID value to the server, we do not need to update our ProductsController Create Action at all to support this new drop-downlist UI - it will just work. If you reference the MVCToolkit assembly, you can optionally take advantage of a useful Extension Method implemented within the System.Web.Mvc.BindingHelpers namespace that can help clean this up a little. It is called "UpdateFrom" and can be used on any .NET object. It takes a dictionary of values as an argument, and it will then automatically perform a property assignment on itself for any key that matches a public property on the object. Note: if you want to be more explicit for security reasons and only allow certain properties to be updated, you can also optionally pass a string array of the property names to update to the UpdateFrom method: "Edit" will display the product form. "Update" will be used to handle the form's submit action. We'll begin enabling our application's Edit functionality by implementing the ProductController's Edit action method. When we created our product listing page at the beginning of this post, we built it so that the Edit action will take an id argument as part of the URL (for example: /Products/Edit/5): We'll want the Edit action method to retrieve the appropriate Product object from the database, as well as retrieve collections of the available Suppliers and Categories (so that we can implement dropdowns in our edit view). We'll define a strongly typed view object to represent all of this using the ProductsEditViewData object below: Note how we are using both the Html.TextBox and Html.Select helper methods in the sample above. Both of these are extension methods from the MVCToolkit.dll assembly. Notice how the Html.Select helper method has an overloaded version that allows you to specify what the selected value is in the dropdownlist. In the snippet below I'm indicating that I want the Category drop down item to be automatically selected based on the edit product's current CategoryID value: Our last step will be to implement the "Update" action method on our ProductController class:
Organisation 2.0 - Le knowledge management nouvelle generation de Martin Roulleaux Dugage
Fier des quelques centaines de milliers de telechargements qu'il a provoques, Ghost Recon Advanced Warfighter 2 devoile aujourd'hui sa nouvelle parure, la Legacy Edition. ...
Sorti en janvier 2007, Lost Planet : Extreme Condition a rencontre un vif succes malgre une difficulte en mode solo qui en a refroidi plus d'un. Capcom, toujours dans les bons coups, nous annoncait il y a quelques jours l'arrivee d'une nouvelle version du soft : Lost Planet : Extreme Condition - Colonies Edition. ...
Yves Saint Laurent a commande aupres du celebre architecte Jean Nouvel la conception d'une edition limitee de bouteilles pour leur parfum L'Homme. Le design de la bouteille est inspire de la forme d'un tube a essai et est emballe dans un bloc de mousse dense noir, enveloppe d'un manchon en carton. On retrouve le monogramme YSL flottant dans la bouteille. Le parfum degage des senteurs fraiches et boisees, des notes de bergamote et de gingembre. www.ysl.com