<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4098916215035045685</id><updated>2024-08-31T18:55:22.657+02:00</updated><category term="ASP.NET MVC 3"/><category term="Divers"/><category term="Visual Studio"/><title type='text'>MickaelDS</title><subtitle type='html'>L&#39;actualité sur le développement Web</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://mickaelds.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4098916215035045685/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://mickaelds.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03133270067493460978</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4098916215035045685.post-770889768789411319</id><published>2012-03-07T18:05:00.000+01:00</published><updated>2012-03-07T18:05:28.513+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio"/><title type='text'>Publication One-Click avec Visual Studio 2010</title><content type='html'>&lt;b&gt;Introduction&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Une fonctionnalité très intéressante de Visual Studio est la publication One-Click. Celà permet assez simplement de publier votre site sur un IIS distant.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Web Deploy 2.0&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Avant toute chose commençons par installer Web Deploy 2.0 disponible ici :&lt;br /&gt;
&lt;ul&gt;&lt;li&gt; http://www.iis.net/download/webdeploy &lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;b&gt;Service de gestion IIS&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Il faut ensuite installer le service de rôle &quot;Service de gestion IIS&quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Web Deploy 2.0&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Il faut maintenant activer ce service via la console d&#39;administration IIS&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgFtovdAlaT8VsXxFwFsMm1tcnX2PTiCCjuGNcYUE7kVnxXnBsNP49iGQY_810E4Rb9FIkNJ54xFigLs0E_QxJA4MNrdhpKyB92-oKwR8iguw3SC7gYKhjvq1SwBTR6fHWBORxprEgtJg/s1600/ActivationService.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;354&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgFtovdAlaT8VsXxFwFsMm1tcnX2PTiCCjuGNcYUE7kVnxXnBsNP49iGQY_810E4Rb9FIkNJ54xFigLs0E_QxJA4MNrdhpKyB92-oKwR8iguw3SC7gYKhjvq1SwBTR6fHWBORxprEgtJg/s400/ActivationService.jpg&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Paramétrage&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Une fois l&#39;installation et l&#39;activation effectuées, reste le paramétrage:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Nous commençons par créer un utilisateur local auquel on affecte le groupe &quot;Utilisateurs&quot;&lt;/li&gt;
&lt;li&gt;Nous ajoutons ensuite cet utilisateur dans les gestionnaires des services Internet via &quot;Autorisation du gestionnaire des service Internet&quot; dans la console d&#39;administration IIS.&lt;/li&gt;
&lt;li&gt;Nous lui attribuons ensuite les droits d&#39;écriture sur le répertoire du site pour lequel nous voulons activer le publish One-Click&lt;/li&gt;
&lt;li&gt;Nous ajoutons ensuite les règles suivantes via &quot;Délégation du service de gestion&quot; en leur attribuant l&#39;utilisateur local déjà créé&lt;/li&gt;
&lt;ul&gt;&lt;li&gt;iisApp&lt;/li&gt;
&lt;li&gt;createApp&lt;/li&gt;
&lt;li&gt;setAcl&lt;/li&gt;
&lt;/ul&gt;&lt;/ul&gt;&lt;br /&gt;
&lt;b&gt;Publication&lt;/b&gt; &lt;br /&gt;
&lt;br /&gt;
Publions maintenant notre site en renseignant les informations nécessaires:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-KGsOZ9xG15LWVLKxfzAhP_G-Gt-9gOoIlLrzw8tE12JNOwILfjFj3L7vhNTAuhTj144YrQZq0-Y1DrQg6-a2kl_LMiNgRm3Rkt8aSKpJMjo04tC5oQwomLLO2HZArivDGZbzUT-DQno/s1600/publish.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;322&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-KGsOZ9xG15LWVLKxfzAhP_G-Gt-9gOoIlLrzw8tE12JNOwILfjFj3L7vhNTAuhTj144YrQZq0-Y1DrQg6-a2kl_LMiNgRm3Rkt8aSKpJMjo04tC5oQwomLLO2HZArivDGZbzUT-DQno/s400/publish.jpg&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5eba52edSAnV9vOX-mXNHUc5TPOcUcMqYh02y-KEaO0-H0MMl-fWcuOucdCthG9Shz_5IcrHo-MlAoSSEh088khl4bVOmJmWWX6CC8Qi83Y56pr0yq3UmB1h9EkVsxGaDCyIjvc28aYU/s1600/publishInfos.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;619&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5eba52edSAnV9vOX-mXNHUc5TPOcUcMqYh02y-KEaO0-H0MMl-fWcuOucdCthG9Shz_5IcrHo-MlAoSSEh088khl4bVOmJmWWX6CC8Qi83Y56pr0yq3UmB1h9EkVsxGaDCyIjvc28aYU/s640/publishInfos.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
A noter que l&#39;URL du service est formatée de la façon suivante:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;http://SERVEUR_IIS:PORT_DU_SERVICE/msdeploy.axd&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;Et que le port est celui par défaut (8172) ou celui que vous avez renseigné lors de l&#39;activation du service des gestion.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mickaelds.blogspot.com/feeds/770889768789411319/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://mickaelds.blogspot.com/2012/03/publication-one-click-avec-visual.html#comment-form' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4098916215035045685/posts/default/770889768789411319'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4098916215035045685/posts/default/770889768789411319'/><link rel='alternate' type='text/html' href='http://mickaelds.blogspot.com/2012/03/publication-one-click-avec-visual.html' title='Publication One-Click avec Visual Studio 2010'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03133270067493460978</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjgFtovdAlaT8VsXxFwFsMm1tcnX2PTiCCjuGNcYUE7kVnxXnBsNP49iGQY_810E4Rb9FIkNJ54xFigLs0E_QxJA4MNrdhpKyB92-oKwR8iguw3SC7gYKhjvq1SwBTR6fHWBORxprEgtJg/s72-c/ActivationService.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4098916215035045685.post-4730319399085523413</id><published>2011-04-06T17:59:00.000+02:00</published><updated>2011-04-06T17:59:08.590+02:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET MVC 3"/><title type='text'>Introduction au moteur de vues RAZOR</title><content type='html'>&lt;b&gt;Introduction&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Une des plus importantes nouveautés de ASP.NET MVC3 est le support du nouveau moteur de vues Razor. Attardons nous quelques instants sur cette nouveauté.&lt;br /&gt;
&lt;br /&gt;
Razor apporte une série d&#39;améliorations à nos vues:&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;La courbe d&#39;apprentissage est particulièrement rapide ; nous&amp;nbsp;appréhenderons&amp;nbsp;plus loin dans cet article la syntaxe de Razor et vous pourrez vous rendre compte par vous-même qu&#39;elle facilite grandement l&#39;apprentissage pour peu qu&#39;on soit familier avec l&#39;ASP.NET classique&lt;/li&gt;
&lt;li&gt;Cette nouvelle syntaxe minimise clairement le nombres de caractères, rendant par la même occasion le code plus lisible et son écriture plus fluide (plus de nécessité d&#39;indiquer des blocs server)&lt;/li&gt;
&lt;li&gt;Grâce à Visual Studio 2010 nous avons accès directement à partir de la vue à un intellisense très complet&lt;/li&gt;
&lt;li&gt;Razor support également les tests unitaires&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;b&gt;Syntaxe&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
@ commence les expressions inline ou les blocs de code, exemple :&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #e7edf6; width: 550px;&quot;&gt;@{string myName=&quot;Mickael&quot;;}&lt;br /&gt;
Bonjour, je m&#39;appelle @myName&lt;/div&gt;&lt;br /&gt;
L&#39;affichage sera : Bonjour je m&#39;appelle Mickael&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Pour info, sachez que l&#39;utilisation de @ encode l&#39;output&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Pour spécifier de façon explicite ce que Razor doit traiter comme expression il faut ajouter (), exemple :&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #e7edf6; width: 550px;&quot;&gt;@{string idProduit=&quot;2&quot;;}&lt;br /&gt;
L&#39;adresse de la fiche produit est : www.monsite.com/FicheProduit.aspx?id_produit=@(idProduit)&amp;amp;mode=1&lt;/div&gt;&lt;br /&gt;
Sachez qu&#39;en doublant @@ vous échapperez ainsi le 2e @&lt;br /&gt;
&lt;br /&gt;
Pour les if, switch, for et foreach, la syntaxe reste identique au c# une fois que vous avez encapsulé votre code dans @{}&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #e7edf6; width: 550px;&quot;&gt;@{&lt;br /&gt;
var isGood=true;&lt;br /&gt;
if(isGood)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;text&amp;gt;c&#39;est bien!&amp;lt;/text&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;lt;text&amp;gt;c&#39;est pas bien!&amp;lt;/text&amp;gt;&lt;br /&gt;
}&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #e7edf6; width: 550px;&quot;&gt;@{&lt;br /&gt;
var myColor=&quot;rouge&quot;;&lt;br /&gt;
var copyColor=&quot;&quot;;&lt;br /&gt;
switch(myColor)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; case &quot;rouge&quot;:&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; copyColor = myColor;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; case &quot;bleu&quot;:&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;/div&gt;&lt;br /&gt;
}&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #e7edf6; width: 550px;&quot;&gt;@for(var i=1 ; i &amp;lt;10 ; i++)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;lt;p&amp;gt;Number @i&amp;lt;/p&amp;gt;&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #e7edf6; width: 550px;&quot;&gt;@foreach(var item in myList)&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;lt;p&amp;gt;Number @item.Number&amp;lt;/p&amp;gt;&lt;br /&gt;
}&lt;/div&gt;&lt;br /&gt;
&lt;b&gt;Conclusion&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Razor est, selon moi, et particulièrement grâce à sa syntaxe et ses parsers un moteur de vues qui atteind son objectif de simplification de code. L&#39;écriture ainsi que la lecture de code deviennent aisées et donc rapides.</content><link rel='replies' type='application/atom+xml' href='http://mickaelds.blogspot.com/feeds/4730319399085523413/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://mickaelds.blogspot.com/2011/04/introduction-au-moteur-de-vues-razor.html#comment-form' title='0 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4098916215035045685/posts/default/4730319399085523413'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4098916215035045685/posts/default/4730319399085523413'/><link rel='alternate' type='text/html' href='http://mickaelds.blogspot.com/2011/04/introduction-au-moteur-de-vues-razor.html' title='Introduction au moteur de vues RAZOR'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03133270067493460978</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4098916215035045685.post-8941525000326310298</id><published>2011-03-25T15:22:00.001+01:00</published><updated>2011-03-25T16:34:56.796+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Divers"/><title type='text'>WebCasts TechDays 2011</title><content type='html'>Pour ceux qui seraient passé à côté, les webcasts des TechDays 2011 sont en ligne :&amp;nbsp;&lt;a href=&quot;http://www.microsoft.com/france/mstechdays/showcase/default.aspx&quot;&gt;http://www.microsoft.com/france/mstechdays/showcase/default.aspx&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://mickaelds.blogspot.com/feeds/8941525000326310298/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://mickaelds.blogspot.com/2011/03/webcasts-techdays-2011.html#comment-form' title='1 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4098916215035045685/posts/default/8941525000326310298'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4098916215035045685/posts/default/8941525000326310298'/><link rel='alternate' type='text/html' href='http://mickaelds.blogspot.com/2011/03/webcasts-techdays-2011.html' title='WebCasts TechDays 2011'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03133270067493460978</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4098916215035045685.post-6204866523934852963</id><published>2011-03-23T13:58:00.006+01:00</published><updated>2012-02-02T18:20:39.879+01:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET MVC 3"/><title type='text'>Introduction à ASP.NET MVC 3</title><content type='html'>Cet article est une première approche de ASP.NET MVC 3, nous allons ici voir les principales nouveautés apportées et les appliquer ensuite dans un exemple.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Introduction&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Pour rappel, MVC (Modèle-Vue-Contrôleur) est un pattern de conception.&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Modèle : le modèle implémente la logique métier&lt;/li&gt;
&lt;li&gt;Vue : la vue correspond à l&#39;interface utilisateur&lt;/li&gt;
&lt;li&gt;Contrôleur : le contrôleur agit comme intermédiaire entre la vue et le modèle&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;b&gt;Principales nouveautés&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Une série d&#39;améliorations ont été apportées grâce et avec Visual Studio 2010.&lt;br /&gt;
&lt;div&gt;&lt;ul&gt;&lt;li&gt;Le template&amp;nbsp;d&#39;un projet ASP.NET MVC 3 inclue maintenant par défaut les dernières versions de JQuery, du plugin de validation JQuery ainsi que JQuery UI (Bibliothèque de composants JQuery&amp;nbsp;&lt;a href=&quot;http://jqueryui.com/&quot;&gt;http://jqueryui.com/&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;NuGet est maintenant installé avec ASP.NET MVC 3 et permet ainsi d&#39;accéder à une large galerie de bibliothèques.&lt;/li&gt;
&lt;li&gt;Un nouveau moteur de vues RAZOR est maintenant disponible. Pour info, ce nouveau moteur a pour principale avantage de simplifier l&#39;écriture et la lisibilité des vues.&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;La validation côté client continue à évoluer. La version 3 d&#39;ASP.NET MVC étant compilée avec le Framework .NET 4.0, nous avons accès à toutes les DataAnnotations apparues dans le Framework .NET 3.5.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;La gestion des action filters a elle aussi évoluée. Il était possible dans la version précédente d&#39;appliquer des action filters à un contrôleur, il maintenant possible de l&#39;étendre à toute l&#39;application en ajoutant notre filtre à la collection GlobalFilters via le fichier Global.asax.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;2 nouveau types d&#39;ActionResult font leur apparition :&amp;nbsp;HttpNotFoundResult et&amp;nbsp;HttpStatusCodeResult.&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;HttpNotFoundResult&amp;nbsp;: Permet de rediriger vers une page 404 avec un message personnalisé&lt;/li&gt;
&lt;li&gt;HttpStatusCodeResult : Permet de gérer l&#39;envoi d&#39;une page avec le status code souhaité&lt;/li&gt;
&lt;/ul&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Côté JavaScript, le moteur d&#39;exécution nous permet maintenant de supporter l&#39;Unobstrusive Javascript que nous détaillerons plus bas.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;La preuve par l&#39;exemple&lt;/b&gt;&lt;br /&gt;
&lt;div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;Commençons par créer un projet de type &lt;i&gt;Application Web ASP.NET MVC 3 &lt;/i&gt;en veillant bien à sélectionner le moteur de vue &lt;i&gt;Razor &lt;/i&gt;ainsi que le template&lt;i&gt; Internet Application&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
Commençons par créer notre model dans le répertoire &lt;i&gt;Models&lt;/i&gt;, nous nommerons notre classe &lt;i&gt;CarModel&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #e7edf6; width: 550px;&quot;&gt;using System.ComponentModel.DataAnnotations;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;public class CarModel&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[Required]&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[Display(Name = &quot;Marque&quot;)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public string Marque { get; set; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[Required]&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[Display(Name = &quot;Modèle&quot;)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public string Modele { get; set; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[Required]&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[Display(Name = &quot;Carburant&quot;)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public string Carburant { get; set; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[Required()]&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;[Display(Name = &quot;Motorisation&quot;)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public string Motorisation { get; set; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;public class Cars&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public Cars()&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CarsList.Add(new CarModel&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Marque = &quot;Volkswagen&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Modele = &quot;Polo&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Carburant = &quot;Diesel&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Motorisation = &quot;1.9 TDI 90&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;});&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CarsList.Add(new CarModel&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Marque = &quot;Volkswagen&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Modele = &quot;Golf&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Carburant = &quot;Diesel&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Motorisation = &quot;1.9 TDI 105&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;});&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CarsList.Add(new CarModel&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Marque = &quot;Volkswagen&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Modele = &quot;Passat&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Carburant = &quot;Diesel&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Motorisation = &quot;2.0 TDI 140&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;});&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CarsList.Add(new CarModel&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Marque = &quot;Volkswagen&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Modele = &quot;Touran&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Carburant = &quot;Diesel&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Motorisation = &quot;2.0 TDI 140&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;});&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;CarsList.Add(new CarModel&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Marque = &quot;Volkswagen&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Modele = &quot;Tiguan&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Carburant = &quot;Diesel&quot;,&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Motorisation = &quot;1.9 TDI 105&quot;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;});&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;public List&amp;lt;CarModel&amp;gt; CarsList = new List&amp;lt;CarModel&amp;gt;();&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
Nous pouvons observer ici l&#39;utilisation des DataAnnotations, pour plus de détails :&amp;nbsp;&lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.aspx&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Nous allons maintenant afficher notre liste de &lt;i&gt;Cars&lt;/i&gt;.&lt;br /&gt;
Ajoutez une référence à votre HomeController créé par défaut afin d&#39;accéder à votre CarModel créé juste avant.&lt;br /&gt;
Ajoutez ensuite le code suivant dans votre méthode &lt;i&gt;Index&lt;/i&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #e7edf6; width: 550px;&quot;&gt;Cars result = new Cars();&lt;br /&gt;
return View(result.CarsList)&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Créez une vue en ayant pris soin de supprimer au préalable la vue Index existante&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Nous pouvons maintenant afficher nos résultats.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Les résultats sont affichés grâce à un tableau, ce qui peut rendre la lecture de notre vue assez compliquée. Différentes solutions sont disponibles pour simplifier notre code.&lt;br /&gt;
Allez dans Références et ajoutez un &quot;Library Package Reference&quot;. Effectuez ensuite une recherche pour&amp;nbsp;&lt;i&gt;microsoft-web-helpers&lt;/i&gt; et installez le package. NuGet nous permet d&#39;installer la dernières version de ce package en quelques secondes.&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;&lt;a href=&quot;https://lh3.googleusercontent.com/-bOSbZOCaCys/TYnU4XdE6bI/AAAAAAAAAEM/SLxaJtiuhDY/s1600/nuget.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;
&lt;/a&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana; font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
Utilisons maintenant le WebGrid fournit par ce package (pour plus d&#39;infos &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/system.web.helpers.webgrid%28v=vs.99%29.aspx&quot;&gt;http://msdn.microsoft.com/en-us/library/system.web.helpers.webgrid(v=vs.99).aspx&lt;/a&gt;)&lt;br /&gt;
Commençons par ajouter les lignes suivantes au fichier de style situé par défaut dans le répertoire &lt;i&gt;Content&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;background-color: #e7edf6; width: 550px;&quot;&gt;/* WebGrid&lt;br /&gt;
-----------------------------------------------------------*/&lt;br /&gt;
.WebGrid{margin:3px;width:400px;border-collapse:collapse;}&lt;br /&gt;
&lt;br /&gt;
.GridHeader{background-color:Silver;font-weight:bold;}&lt;br /&gt;
&lt;br /&gt;
.WebGrid th, .WebGrid td{border:1px solid black;padding:2px;}&lt;br /&gt;
&lt;br /&gt;
.AlternateGrid{background-color:Gray;}&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
Modifions maintenant notre vue de la façon suivante:&lt;/div&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: #e7edf6; width: 550px;&quot;&gt;@model IEnumerable&lt;mymvc.models.carmodel&gt;&lt;br /&gt;
&lt;br /&gt;
@{&lt;br /&gt;
ViewBag.Title = &quot;Index&quot;;&lt;br /&gt;
Layout = &quot;~/Views/Shared/_Layout.cshtml&quot;;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
@{&lt;br /&gt;
var webGrid = new WebGrid(source: Model, canPage: true, rowsPerPage: 2);&lt;br /&gt;
webGrid.Pager(WebGridPagerModes.Numeric);&lt;br /&gt;
@webGrid.GetHtml(tableStyle:&quot;WebGrid&quot;,&lt;br /&gt;
headerStyle:&quot;GridHeader&quot;,&lt;br /&gt;
alternatingRowStyle:&quot;AlternateGrid&quot;,&lt;br /&gt;
columns:webGrid.Columns(webGrid.Column(&quot;Marque&quot;, &quot;Marque&quot;, canSort:true),&lt;br /&gt;
webGrid.Column(&quot;Modele&quot;,&quot;Modèle&quot;,canSort:true),&lt;br /&gt;
webGrid.Column(&quot;Carburant&quot;,&quot;Carburant&quot;,canSort:true),&lt;br /&gt;
webGrid.Column(&quot;Motorisation&quot;, &quot;Motorisation&quot;, canSort: true)));&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;/mymvc.models.carmodel&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div&gt;Nous obtenons ainsi une WebGrid avec la gestion de la pagination et du tri en seulement quelques lignes.&lt;br /&gt;
&lt;br /&gt;
------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
A une prochaine fois dans un autre post! :)&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mickaelds.blogspot.com/feeds/6204866523934852963/comments/default' title='Publier les commentaires'/><link rel='replies' type='text/html' href='http://mickaelds.blogspot.com/2011/03/introduction-aspnet-mvc-3.html#comment-form' title='1 commentaires'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4098916215035045685/posts/default/6204866523934852963'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4098916215035045685/posts/default/6204866523934852963'/><link rel='alternate' type='text/html' href='http://mickaelds.blogspot.com/2011/03/introduction-aspnet-mvc-3.html' title='Introduction à ASP.NET MVC 3'/><author><name>Anonymous</name><uri>http://www.blogger.com/profile/03133270067493460978</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>