<?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-4172426161974972492</id><updated>2026-10-12T05:03:38.570+05:30</updated><category term=".NET"/><category term=".NET9"/><category term="MVC 5.0"/><category term="C#13"/><category term="MVC"/><category term="ActionResult"/><category term="C# 6.0"/><category term="LINQ"/><category term="Visual Studio 2013"/><category term="Visual Studio 2015"/><category term="AngularJS"/><category term="CountBy"/><category term="GUID"/><category term="PartialViewResult"/><category term="AggregateBy"/><category term="IEnumerable"/><category term="Index"/><category term="LESS"/><category term="Multi-language"/><category term="Params"/><category term="Properties"/><category term="SearchValues"/><category term="Skype"/><category term="Task"/><category term="UUID"/><category term="ViewResult"/><category term="Visual Studio"/><category term="Visual Studio 2022"/><category term="Web Essentials"/><category term="async"/><category term="await"/><title type='text'>Ramchand&#39;s Blog</title><subtitle type='html'>Learn, Share and feel the difference</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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>29</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-2656422496191124694</id><published>2025-02-04T12:22:00.003+05:30</published><updated>2025-02-04T12:25:19.177+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET9"/><category scheme="http://www.blogger.com/atom/ns#" term="C#13"/><category scheme="http://www.blogger.com/atom/ns#" term="CountBy"/><category scheme="http://www.blogger.com/atom/ns#" term="GUID"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio 2022"/><title type='text'></title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;.NET 9 Features&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;ol style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2025/01/taskwheneach-in-net9.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;Task.WhenEach in .NET 9&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-countby-linq.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;CountBy LINQ in .NET 9&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-aggregateby-linq.html&quot;&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;AggregateBy LINQ in .NET 9&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-index-in-linq.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;Index LINQ in .NET 9&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/uuid-v7-in-net-9.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;UUID v7 in .NET9&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2025/01/searchvalues-improvements-in-net9.html&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;SearchValues improvements in .NET9&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2025/01/semi-auto-properties-in-net9.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;Semi Auto Properties in .NET9&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2025/02/params-collections-in-net9.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;&lt;span style=&quot;color: #2b00fe;&quot;&gt;Params Collection in .NET9&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/2656422496191124694/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2025/02/csharp features.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/2656422496191124694'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/2656422496191124694'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2025/02/csharp features.html' title=''/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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-4172426161974972492.post-3394739547546885068</id><published>2025-02-04T11:56:00.004+05:30</published><updated>2025-02-04T11:59:10.788+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET9"/><category scheme="http://www.blogger.com/atom/ns#" term="C#13"/><category scheme="http://www.blogger.com/atom/ns#" term="IEnumerable"/><category scheme="http://www.blogger.com/atom/ns#" term="Params"/><title type='text'>Params Collections in .NET9</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;About&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The series of features exploring in .NET 9 posts, This post, we are focusing on &quot;Params Collections&quot; feature in .NET9. Please refer the following links for other .NET 9 features discussed in my earlier posts.&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2025/01/taskwheneach-in-net9.html&quot; target=&quot;_blank&quot;&gt;Task.WhenEach in .NET 9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-countby-linq.html&quot; target=&quot;_blank&quot;&gt;CountBy LINQ in .NET 9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-aggregateby-linq.html&quot;&gt;AggregateBy LINQ in .NET 9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-index-in-linq.html&quot; target=&quot;_blank&quot;&gt;Index LINQ in .NET 9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/uuid-v7-in-net-9.html&quot; target=&quot;_blank&quot;&gt;UUID v7 in .NET9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2025/01/searchvalues-improvements-in-net9.html&quot; target=&quot;_blank&quot;&gt;SearchValues improvements in .NET9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2025/01/semi-auto-properties-in-net9.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Semi Auto Properties in .NET9&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Introduction&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Params collection is one of the feature in C#13. This params parameter can be of any types supported for collection parameters.&lt;/div&gt;&lt;div&gt;This enhanced feature helps to write code in cleaner way and it also improves in performance point of view as well.&lt;/div&gt;&lt;div&gt;Lets explore and understand about this with sample code by comparing before .NET9 and now.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Before .NET 9&lt;/span&gt;&lt;/h3&gt;
&lt;pre&gt;&lt;code style=&quot;background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); display: block; overflow: auto; padding: 20px;&quot;&gt; //Before .NET 9
 public static void PrintNumbers( params int[] numbers)
 {
     Console.WriteLine(&quot;Numbers in Array: &quot; + string.Join(&quot;, &quot;, numbers));
 }
 public static void PrintNumbers(List&lt;int&gt; numbers)
 {
     Console.WriteLine(&quot;Numbers in List: &quot; + string.Join(&quot;, &quot;, numbers));
 }

&lt;/int&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;div&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;.NET 9&lt;/span&gt;&lt;/h3&gt;
&lt;pre&gt;&lt;code style=&quot;background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); display: block; overflow: auto; padding: 20px;&quot;&gt; // .NET 9
public static void PrintNumbersInNET9(params ReadOnlySpan&lt;int&gt; numbers)
{
    Console.WriteLine(&quot;Numbers in ReadOnlySpan: &quot; + string.Join(&quot;, &quot;, numbers.ToArray()));
}

public static void PrintNumbersInNET9(params IEnumerable&lt;int&gt; numbers)
{
    Console.WriteLine(&quot;Numbers in IEnumerable: &quot; + string.Join(&quot;, &quot;, numbers));
}
&lt;/int&gt;&lt;/int&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Call those methods&amp;nbsp; just like below.&lt;/p&gt;
&lt;pre&gt;&lt;code style=&quot;background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); display: block; overflow: auto; padding: 20px;&quot;&gt;
// Using params with a Array or List
var numbersList = new List&lt;int&gt; { 6, 7, 8 };
ParamsCollection.PrintNumbers(numbersList.ToArray());
ParamsCollection.PrintNumbers(numbersList);

// Using params with ReadOnlySpan
ParamsCollection.PrintNumbersInNET9([6, 7, 8]);

// Using params with List
ParamsCollection.PrintNumbersInNET9(numbersList.Where(x =&amp;gt; x &amp;gt; 6));
&lt;/int&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The aforesaid scenario where you have two method overloads: one accepting &lt;code&gt;params IEnumerable&amp;lt;T&amp;gt;&lt;/code&gt; and another taking &lt;code&gt;params ReadOnlySpan&amp;lt;T&amp;gt;&lt;/code&gt;. The method resolution works as follows:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;When passing a sequence of values directly, the &lt;code&gt;params ReadOnlySpan&amp;lt;T&amp;gt;&lt;/code&gt; overload is chosen.&lt;/li&gt;&lt;li&gt;If an array is provided as an argument, the &lt;code&gt;params ReadOnlySpan&amp;lt;T&amp;gt;&lt;/code&gt; overload is also selected, since arrays can be implicitly converted to &lt;code&gt;ReadOnlySpan&amp;lt;T&amp;gt;&lt;/code&gt;.&lt;/li&gt;&lt;li&gt;However, when a &lt;code&gt;List&amp;lt;T&amp;gt;&lt;/code&gt; is passed, the &lt;code&gt;params IEnumerable&amp;lt;T&amp;gt;&lt;/code&gt; overload is preferred, as &lt;code&gt;List&amp;lt;T&amp;gt;&lt;/code&gt; implements &lt;code&gt;IEnumerable&amp;lt;T&amp;gt;&lt;/code&gt; but does not have an implicit conversion to &lt;code&gt;ReadOnlySpan&amp;lt;T&amp;gt;&lt;/code&gt;.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Code Screenshots&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; color: #e69138; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEih1FXMxT7x4J2eiYZSfdrWqKwN8e5_ZhwZSyYmwTfnF1tYLfb5gVQ4YjLlR7IOpo8bWtdNLwsOWxtKiarHNMKaywZ7vKSka3V61p3SbKAfOof5PV2VKVGb34CnMlJnjj5Zv9yLiVqrnNoB3ElbGT879tQOtAAEBYmhoLfPT0k_oN-BDcKi-iWyxx6RsWk&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;486&quot; data-original-width=&quot;732&quot; height=&quot;424&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEih1FXMxT7x4J2eiYZSfdrWqKwN8e5_ZhwZSyYmwTfnF1tYLfb5gVQ4YjLlR7IOpo8bWtdNLwsOWxtKiarHNMKaywZ7vKSka3V61p3SbKAfOof5PV2VKVGb34CnMlJnjj5Zv9yLiVqrnNoB3ElbGT879tQOtAAEBYmhoLfPT0k_oN-BDcKi-iWyxx6RsWk=w640-h424&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; color: #e69138; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&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/a/AVvXsEieeUjNmQa0sFQA0easoBUTfbKOSyOoDWmk-LC0AqCcEU-gWeQr1YerbUe5HXHi99HSDjqUQSQ0EHUG7xc3jjFbpYkAxI1Qs2lf3H3UKHRt0twTOE8rqKKsRqZaFs_3wFD7niQgsIlVzm9F-fZk-EGNSUZHd8NPnAVAb_CQfGM4cd5xevu_jwyVkPU0LTI&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;179&quot; data-original-width=&quot;566&quot; height=&quot;202&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEieeUjNmQa0sFQA0easoBUTfbKOSyOoDWmk-LC0AqCcEU-gWeQr1YerbUe5HXHi99HSDjqUQSQ0EHUG7xc3jjFbpYkAxI1Qs2lf3H3UKHRt0twTOE8rqKKsRqZaFs_3wFD7niQgsIlVzm9F-fZk-EGNSUZHd8NPnAVAb_CQfGM4cd5xevu_jwyVkPU0LTI=w640-h202&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; color: #e69138; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; color: #e69138; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgGopiXBg14yIUJNMUsU79GU1TZIj5GlDzKY_YN8GKbv6m16CeznBoCGfLt6iri1JV7lfb0dLHeY_RqouKPH0W5uB5Xi51gtV-w_6f4k5wzHgU4cY8G5BsmTx4FiO1ucJhoNvxataMCBkI4LqsdLxZbNx_oPMakEfEkTP2jKpND-QTTM1WaTdeizgHTyDw&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;240&quot; data-original-width=&quot;814&quot; height=&quot;188&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgGopiXBg14yIUJNMUsU79GU1TZIj5GlDzKY_YN8GKbv6m16CeznBoCGfLt6iri1JV7lfb0dLHeY_RqouKPH0W5uB5Xi51gtV-w_6f4k5wzHgU4cY8G5BsmTx4FiO1ucJhoNvxataMCBkI4LqsdLxZbNx_oPMakEfEkTP2jKpND-QTTM1WaTdeizgHTyDw=w640-h188&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; color: #e69138; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;color: black; text-align: left;&quot;&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Summary&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Params collection feature provides these following benefits.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Cleaner code:&amp;nbsp;&lt;/b&gt;It reduces the number of calls to &lt;i&gt;.ToArray()&lt;/i&gt; and &lt;i&gt;.ToList()&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;b&gt;Performance:&lt;/b&gt; Methods like &lt;code&gt;.ToArray()&lt;/code&gt; and &lt;code&gt;.ToList()&lt;/code&gt; inherently introduce additional resource overhead. However, the updated implementation now supports passing &lt;code&gt;Span&amp;lt;&amp;gt;&lt;/code&gt; and &lt;code&gt;IEnumerable&amp;lt;&amp;gt;&lt;/code&gt;, optimizing memory usage and enabling lazy execution. This enhancement improves efficiency while offering greater flexibility for performance-critical scenarios.&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: justify;&quot;&gt;Thanks for your reading and as always share your feedback on this.&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;

</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/3394739547546885068/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2025/02/params-collections-in-net9.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/3394739547546885068'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/3394739547546885068'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2025/02/params-collections-in-net9.html' title='Params Collections in .NET9'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/a/AVvXsEih1FXMxT7x4J2eiYZSfdrWqKwN8e5_ZhwZSyYmwTfnF1tYLfb5gVQ4YjLlR7IOpo8bWtdNLwsOWxtKiarHNMKaywZ7vKSka3V61p3SbKAfOof5PV2VKVGb34CnMlJnjj5Zv9yLiVqrnNoB3ElbGT879tQOtAAEBYmhoLfPT0k_oN-BDcKi-iWyxx6RsWk=s72-w640-h424-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-6617623909046650865</id><published>2025-01-17T21:27:00.003+05:30</published><updated>2025-01-17T21:30:42.356+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET9"/><category scheme="http://www.blogger.com/atom/ns#" term="C#13"/><category scheme="http://www.blogger.com/atom/ns#" term="Properties"/><title type='text'>Semi Auto Properties in .NET9</title><content type='html'>&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;About&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The series of features exploring in .NET 9 posts, This post, we are focusing on &quot;Semi Auto Properties&quot; feature in .NET9. Please refer the following links for other .NET 9 features discussed in my earlier posts.&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2025/01/taskwheneach-in-net9.html&quot; target=&quot;_blank&quot;&gt;Task.WhenEach in .NET 9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-countby-linq.html&quot; target=&quot;_blank&quot;&gt;CountBy LINQ in .NET 9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-aggregateby-linq.html&quot;&gt;AggregateBy LINQ in .NET 9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-index-in-linq.html&quot; target=&quot;_blank&quot;&gt;Index LINQ in .NET 9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/uuid-v7-in-net-9.html&quot; target=&quot;_blank&quot;&gt;UUID v7 in .NET9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2025/01/searchvalues-improvements-in-net9.html&quot; target=&quot;_blank&quot;&gt;SearchValues improvements in .NET9&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Introduction&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;Semi Auto Properties is available in&amp;nbsp;&lt;b&gt;Preview&lt;/b&gt; feature of C#13. This feature really helps Enhanced readability and reduced boilerplate code while declaring properties in class files.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;Lets understand further by exploring more following information.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;Usually,&amp;nbsp;&lt;/span&gt;In C#, We declare an auto-implemented property like&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;code&gt;public int EmplSalary { get; set; }&lt;/code&gt;,&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The compiler automatically generates a backing field like (Ex:&amp;nbsp;&lt;code&gt;_empSalary)&lt;/code&gt;&amp;nbsp;and internal getter/setter methods (&lt;code&gt;void set_EmplSalary(int empSalary)&lt;/code&gt; and &lt;code&gt;int get_EmplSalary()&lt;/code&gt;).&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;However, In our real-time project cases, we need to set some custom logic such as validation, default values, computations, or lazy loading in the property’s getter or setter, we typically need to manually define the backing field.&amp;nbsp;&lt;/div&gt;&lt;div&gt;With C# 13 preview, this process is simplified by the introduction of the &lt;b&gt;&lt;code&gt;field&lt;/code&gt; &lt;/b&gt;keyword, which allows direct access to the backing field without the need for manual definition.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Edit the project file by adding&amp;nbsp;&lt;b&gt;&amp;lt;LangVersion&amp;gt;preview&amp;lt;/LangVersion&amp;gt;. &lt;/b&gt;So, It supports &lt;b&gt;field&lt;/b&gt;&lt;/div&gt;&lt;div&gt;property in project usage.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&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/a/AVvXsEhdSzV8OTSiXODo_Ey-qKaJrRNy3Qo3N99QrykM-Pw1kMmQz4eWIcZBmUpcXX509P6_ggSaz6lzfbxVgVUYYNh6dccu_CR2d6uYppNIXy74TdYDuMfuIXGeZYpwJ0CmnffKBKoO0mVYKRW9ka3tY1MCzCwxC3IvsN96PPkVZlkHxTrVeQvvqD3VWNJ5gNQ&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;217&quot; data-original-width=&quot;413&quot; height=&quot;168&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhdSzV8OTSiXODo_Ey-qKaJrRNy3Qo3N99QrykM-Pw1kMmQz4eWIcZBmUpcXX509P6_ggSaz6lzfbxVgVUYYNh6dccu_CR2d6uYppNIXy74TdYDuMfuIXGeZYpwJ0CmnffKBKoO0mVYKRW9ka3tY1MCzCwxC3IvsN96PPkVZlkHxTrVeQvvqD3VWNJ5gNQ&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;The following code gives more illustrative idea about usage.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Before .NET 9&lt;/span&gt;&lt;/h3&gt;
 &lt;pre&gt;&lt;code style=&quot;background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); display: block; overflow: auto; padding: 20px;&quot;&gt;
private int _empSalary;

public int EmpSalary
{
    get =&amp;gt; _empSalary;
    set
    {
        if (value &amp;lt;= 0)
            throw new ArgumentOutOfRangeException(nameof(value),
                &quot;Salary must be greater than 0&quot;);
        _empSalary = value;
    }
}
&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;In .NET 9&lt;/span&gt;&lt;/h3&gt;
  &lt;pre&gt;&lt;code style=&quot;background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); display: block; overflow: auto; padding: 20px;&quot;&gt;
public int EmployeeSalary
{
    get =&amp;gt; field;
    set
    {
        if (value &amp;lt;= 0)
            throw new ArgumentOutOfRangeException(nameof(value),
                &quot;Salary must be greater than 0&quot;);
        field = value;
    }
}
&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Code Screenshot&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&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/a/AVvXsEjrj7XZ7MEuhPK5A6SSIzF1qOYRu-u0P818wShRW5AKe-sLwqCZiOGKT3hdZMjsnG0-Wqz8R8iD5WIa_W6aSlgiR2bJM9TNARYvawioEcbntgRQG6aNMok3_MwnP81XR_UvUiPzRXcTp25KSDy2EhQqBiL_4Xr0RopCTLLBa1pcOWT9c8akoVuUANc4nOc&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;654&quot; data-original-width=&quot;546&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjrj7XZ7MEuhPK5A6SSIzF1qOYRu-u0P818wShRW5AKe-sLwqCZiOGKT3hdZMjsnG0-Wqz8R8iD5WIa_W6aSlgiR2bJM9TNARYvawioEcbntgRQG6aNMok3_MwnP81XR_UvUiPzRXcTp25KSDy2EhQqBiL_4Xr0RopCTLLBa1pcOWT9c8akoVuUANc4nOc=w533-h640&quot; width=&quot;533&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;Thanks for your reading and please share your feedback on comments.</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/6617623909046650865/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2025/01/semi-auto-properties-in-net9.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/6617623909046650865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/6617623909046650865'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2025/01/semi-auto-properties-in-net9.html' title='Semi Auto Properties in .NET9'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/a/AVvXsEhdSzV8OTSiXODo_Ey-qKaJrRNy3Qo3N99QrykM-Pw1kMmQz4eWIcZBmUpcXX509P6_ggSaz6lzfbxVgVUYYNh6dccu_CR2d6uYppNIXy74TdYDuMfuIXGeZYpwJ0CmnffKBKoO0mVYKRW9ka3tY1MCzCwxC3IvsN96PPkVZlkHxTrVeQvvqD3VWNJ5gNQ=s72-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-5884027874812265955</id><published>2025-01-06T21:02:00.003+05:30</published><updated>2025-01-06T21:02:57.877+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET9"/><category scheme="http://www.blogger.com/atom/ns#" term="async"/><category scheme="http://www.blogger.com/atom/ns#" term="await"/><category scheme="http://www.blogger.com/atom/ns#" term="C#13"/><category scheme="http://www.blogger.com/atom/ns#" term="Task"/><title type='text'>Task.WhenEach in .NET9</title><content type='html'>&lt;h3 style=&quot;text-align: left;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #e69138;&quot;&gt;About&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The series of features exploring in .NET 9 posts, This post, we are focusing on &quot;Task.WhenEach&quot; feature in .NET9. Please refer the following links for other .NET 9 features discussed in my earlier posts.&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-countby-linq.html&quot; target=&quot;_blank&quot;&gt;CountBy LINQ in .NET 9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-aggregateby-linq.html&quot;&gt;AggregateBy LINQ in .NET 9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-index-in-linq.html&quot; target=&quot;_blank&quot;&gt;Index LINQ in .NET 9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/uuid-v7-in-net-9.html&quot; target=&quot;_blank&quot;&gt;UUID v7 in .NET9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2025/01/searchvalues-improvements-in-net9.html&quot; target=&quot;_blank&quot;&gt;SearchValues improvements in .NET9&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Introduction&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;Task.WhenEach is introduced in C#13 of .NET9. This is really helpful when we have list of tasks that completes in different time intervals and then we want to start other task as soon as it completes the current one.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;The below code example illustrates the usage of this feature by comparing/understand the earlier version with current version as well.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;
&lt;pre&gt;&lt;code style=&quot;background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); display: block; overflow: auto; padding: 20px;&quot;&gt;
public async Task TaskWhenEachFeature()
{
    // Before            
    var tasks1 = Enumerable.Range(1, 5)
       .Select(async i =&amp;gt;
       {
           await Task.Delay(1000);
           return $&quot;Task is {i} done in earlier.&quot;;
       })
       .ToList();

    
    while (tasks1.Count &amp;gt; 0)
    {
        var completedTask = await Task.WhenAny(tasks1);
        tasks1.Remove(completedTask);
        Console.WriteLine(await completedTask);
    }

    // .NET 9 USAGE OF Task.WhenEach feature
    Console.WriteLine(&quot;==.NET9 - Task.WhenEach feature&quot;);
    var tasks2 = Enumerable.Range(1, 5)
       .Select(async i =&amp;gt;
       {
           await Task.Delay(2000);
           return $&quot;Task In .NET9 {i} done&quot;;
       })
       .ToList();
    await foreach (var completedTask in Task.WhenEach(tasks2))
        Console.WriteLine(await completedTask);
}
&lt;/code&gt;&lt;/pre&gt;
 &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Screenshots&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&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/a/AVvXsEgtq-RMXw50Fk-mbGAdKynLsLodBWFDH_az5DumOHgxmFshLyDjJs1ezJ4bH_5mRUrMl0O7K6daurk8B8LYXB_sMc3TFVc5t7_OULPC0kLYzHycUcsCcPZ7LRuXgGq8aRrYf8y1ygUY4-8ZbaS_oKsNm8oarUFKvd0XT895A6iXnGgsOx7L-ZrnymQYZLk&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;551&quot; data-original-width=&quot;521&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgtq-RMXw50Fk-mbGAdKynLsLodBWFDH_az5DumOHgxmFshLyDjJs1ezJ4bH_5mRUrMl0O7K6daurk8B8LYXB_sMc3TFVc5t7_OULPC0kLYzHycUcsCcPZ7LRuXgGq8aRrYf8y1ygUY4-8ZbaS_oKsNm8oarUFKvd0XT895A6iXnGgsOx7L-ZrnymQYZLk=w605-h640&quot; width=&quot;605&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;h3 style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Output&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&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/a/AVvXsEilluHNezS46q4AwO88ExQ13gFFgniNZhM5jGqdwzo5lljIdeat0RphOnB9GV2Rv_JdC-4yZgjoA-Qo1d4V9pSb813u-8aI2-sz5rooEYfOiaFxBYu77Mj--HA8iu7dZOa_TFSmuZuhp9AQdtGvcKwpYjYb3jLcDOblClvqO-cg_jNx_LyMs3AqAp3Nm4Y&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;505&quot; data-original-width=&quot;767&quot; height=&quot;264&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEilluHNezS46q4AwO88ExQ13gFFgniNZhM5jGqdwzo5lljIdeat0RphOnB9GV2Rv_JdC-4yZgjoA-Qo1d4V9pSb813u-8aI2-sz5rooEYfOiaFxBYu77Mj--HA8iu7dZOa_TFSmuZuhp9AQdtGvcKwpYjYb3jLcDOblClvqO-cg_jNx_LyMs3AqAp3Nm4Y=w525-h264&quot; width=&quot;525&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/5884027874812265955/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2025/01/taskwheneach-in-net9.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/5884027874812265955'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/5884027874812265955'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2025/01/taskwheneach-in-net9.html' title='Task.WhenEach in .NET9'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/a/AVvXsEgtq-RMXw50Fk-mbGAdKynLsLodBWFDH_az5DumOHgxmFshLyDjJs1ezJ4bH_5mRUrMl0O7K6daurk8B8LYXB_sMc3TFVc5t7_OULPC0kLYzHycUcsCcPZ7LRuXgGq8aRrYf8y1ygUY4-8ZbaS_oKsNm8oarUFKvd0XT895A6iXnGgsOx7L-ZrnymQYZLk=s72-w605-h640-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-7696607280459044372</id><published>2025-01-01T16:06:00.004+05:30</published><updated>2025-01-01T16:14:00.336+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET9"/><category scheme="http://www.blogger.com/atom/ns#" term="C#13"/><category scheme="http://www.blogger.com/atom/ns#" term="SearchValues"/><title type='text'>SearchValues Improvements in .NET9</title><content type='html'>&lt;h3 style=&quot;text-align: left;&quot;&gt;&amp;nbsp;&lt;span style=&quot;color: #e69138;&quot;&gt;About&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The series of features exploring in .NET 9 posts, This post, we are focusing on &quot;SearchValues&quot; improvements did in .NET9. Please refer the following links for other .NET 9 features discussed in my earlier posts.&lt;/div&gt;&lt;div&gt;&lt;ul&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-countby-linq.html&quot; target=&quot;_blank&quot;&gt;CountBy LINQ in .NET 9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-aggregateby-linq.html&quot;&gt;AggregateBy LINQ in .NET 9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-index-in-linq.html&quot; target=&quot;_blank&quot;&gt;Index LINQ in .NET 9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/uuid-v7-in-net-9.html&quot; target=&quot;_blank&quot;&gt;UUID v7 in .NET9&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Introduction&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;SearchValues was introduced in .NET8 to perform searching more efficiently compared to earlier method of using ICollection.Contains method. However, in .NET8, Its limited to set of characters or bytes.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;So, .NET9 its upgraded to support string as well instead of only character.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;Lets explore the usage of&amp;nbsp; &quot;SearchValues&quot; usage in both .NET8 and .NET9 versions.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;The below code example shows the usage of this feature in both .NET versions.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;We can see that, .NET9 search supports string comparison type as well.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code style=&quot;background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); display: block; overflow: auto; padding: 20px;&quot;&gt;
public static void SearchValuesFeature()
{
    var message = &quot;Explore new feature of SearchValues improvements in .NET9&quot;.AsSpan();

    // .NET 8
    var charSearch = SearchValues.Create([&#39;.&#39;,&#39;N&#39;, &#39;E&#39;, &#39;T&#39;]);
    Console.WriteLine(message.ContainsAny(charSearch));

    // .NET 9
    var wordSearch = SearchValues.Create([&quot;.NET9&quot;, &quot;of&quot;], StringComparison.OrdinalIgnoreCase);
    Console.WriteLine(message.ContainsAny(wordSearch));
}
&lt;/code&gt;&lt;/pre&gt;&lt;div&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Screenshots&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&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/a/AVvXsEhLWUr-YgzC3--eAi7QOdWK8eNpmTeW2oaIzVzNRE9r2eAZiQ_EL_agio4h1PGMpdzQ8wTfpO3ZpgLkc2dK3yfKoyj5W3gBAG_Dykfnj4I9D0Z9GENm5BdMNRG3tm0uuH2Gl6r3AUitylq5Wg7djWMEOv8v2z02IzXF73bZjoEBv6MJbuecVaN5rp5sSPM&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;219&quot; data-original-width=&quot;741&quot; height=&quot;190&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhLWUr-YgzC3--eAi7QOdWK8eNpmTeW2oaIzVzNRE9r2eAZiQ_EL_agio4h1PGMpdzQ8wTfpO3ZpgLkc2dK3yfKoyj5W3gBAG_Dykfnj4I9D0Z9GENm5BdMNRG3tm0uuH2Gl6r3AUitylq5Wg7djWMEOv8v2z02IzXF73bZjoEBv6MJbuecVaN5rp5sSPM=w620-h190&quot; width=&quot;620&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Summary&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;This feature is defiantly used option in our day to day projects/development where we used to do search operations,&amp;nbsp; data input filter scenarios, spam detection checks and many more.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;Thanks for your reading!!&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/7696607280459044372/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2025/01/searchvalues-improvements-in-net9.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/7696607280459044372'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/7696607280459044372'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2025/01/searchvalues-improvements-in-net9.html' title='SearchValues Improvements in .NET9'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/a/AVvXsEhLWUr-YgzC3--eAi7QOdWK8eNpmTeW2oaIzVzNRE9r2eAZiQ_EL_agio4h1PGMpdzQ8wTfpO3ZpgLkc2dK3yfKoyj5W3gBAG_Dykfnj4I9D0Z9GENm5BdMNRG3tm0uuH2Gl6r3AUitylq5Wg7djWMEOv8v2z02IzXF73bZjoEBv6MJbuecVaN5rp5sSPM=s72-w620-h190-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-1908847720740535768</id><published>2024-12-18T22:08:00.004+05:30</published><updated>2024-12-19T21:35:30.876+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET9"/><category scheme="http://www.blogger.com/atom/ns#" term="C#13"/><category scheme="http://www.blogger.com/atom/ns#" term="GUID"/><category scheme="http://www.blogger.com/atom/ns#" term="UUID"/><title type='text'>UUID v7 in .NET 9</title><content type='html'>&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;About&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;.NET 9 comes up with so many excited features as discussed in earlier posts. This post, we are focusing on &lt;b&gt;UUID v7&lt;/b&gt; feature.&lt;/div&gt;&lt;div&gt;Please refer the following links for other .NET 9 LINQ features&lt;/div&gt;&lt;div&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-countby-linq.html&quot; target=&quot;_blank&quot;&gt;CountBy LINQ in .NET 9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-aggregateby-linq.html&quot;&gt;AggregateBy LINQ in .NET 9&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-index-in-linq.html&quot; target=&quot;_blank&quot;&gt;Index LINQ in .NET 9&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Introduction&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;The earlier versions of .NET, we&#39;ve used Guid.NewGuid() (version 4) method generate UUIDs. It simply generates unique identifier which being used in our projects.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The present .NET 9 version supports UUID v7 format of code like&amp;nbsp;&lt;b&gt;Guid.CreateVersion7(). &lt;/b&gt;This generated UUID incorporated&amp;nbsp;&lt;b&gt;timestamp &lt;/b&gt;already in it. &lt;span style=&quot;color: #bf9000;&quot;&gt;So, This is really very helpful when we stored this UUID in database level to &lt;b&gt;Sort &lt;/b&gt;it&amp;nbsp; based on creation time.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #bf9000;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;The structure of UUID format is as follows.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;&lt;u&gt;&amp;nbsp;48-bit timestamp || 12-bit random ||&amp;nbsp; &amp;nbsp; 62-bit random&lt;/u&gt;&lt;/i&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;i&gt;48-bit timestamp:&lt;/i&gt; It represents the number of milliseconds since Unix epoch. so, It provides info about creation time.&lt;/div&gt;&lt;div&gt;&lt;i&gt;12-bit random:&lt;/i&gt; It adds randomness to ensure uniqueness in within same millisecond.&lt;/div&gt;&lt;div&gt;&lt;i&gt;62-bit random:&lt;/i&gt; It also ensures overall uniqueness by offering randomness of entropy.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Code Examples&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;b&gt;Before .NET 9&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code style=&quot;background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); display: block; overflow: auto; padding: 20px;&quot;&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;var guid = Guid.NewGuid(); // v4 UUID&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b style=&quot;color: #e69138; font-size: medium;&quot;&gt;.NET 9&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b style=&quot;color: #e69138; font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;var guidv7 = Guid.CreateVersion7(); // v7 UUID&lt;/span&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code style=&quot;background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); display: block; overflow: auto; padding: 20px;&quot;&gt;&lt;span style=&quot;background-color: transparent;&quot;&gt;var guidv7 = Guid.CreateVersion7(); // v7 UUID&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div&gt;This by default inherits UtcNow timeformat.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Lets explore about Sort feature by creating multiple UUIDs custom way.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;//Just added the guid by adding different time provider by add/subtract minutes to current Utc time.&lt;/div&gt;&lt;div&gt;
  &lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code style=&quot;background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); display: block; overflow: auto; padding: 20px;&quot;&gt;var guidList = new List&lt;guid&gt;
{
    Guid.CreateVersion7(TimeProvider.System.GetUtcNow()),
    Guid.CreateVersion7(TimeProvider.System.GetUtcNow().AddMinutes(-10)),
    Guid.CreateVersion7(TimeProvider.System.GetUtcNow().AddMinutes(10)),
    Guid.CreateVersion7(TimeProvider.System.GetUtcNow().AddMinutes(-20))

};
//write the guids in whatever list contains.
foreach (var v7guid in guidList)
{
    Console.WriteLine(v7guid.ToString());
}

Console.WriteLine(&quot;=====================&quot;);
//Order the guidlist and then write list.
//The result you can identify guids are ordered based on creation time.
var sortedList = guidList.OrderBy(x =&amp;gt; x).ToList();
foreach (var v7guid in sortedList)
{
    Console.WriteLine(v7guid.ToString());
}
&lt;/guid&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Screenshots&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&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/AVvXsEhyviFHMuA_2JQrmFpn1j9gsYmyR84_8r4tI586G_ZekfDVhF9TwH1SCRf6TOovHEh8bv4k13ae1XlE-VtRP_GvvGa0xwX9GGpHG5QdIsI9_Ro8fFmueQAJqGy0T6tv6XSdPYvbiGcM3lPptlJz0TxgcS5QTvv-XxhVFydB7u7kS5VMrTRo7gfRpgd7AFs/s621/Screenshot%202024-12-18%20220029.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;497&quot; data-original-width=&quot;621&quot; height=&quot;512&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhyviFHMuA_2JQrmFpn1j9gsYmyR84_8r4tI586G_ZekfDVhF9TwH1SCRf6TOovHEh8bv4k13ae1XlE-VtRP_GvvGa0xwX9GGpHG5QdIsI9_Ro8fFmueQAJqGy0T6tv6XSdPYvbiGcM3lPptlJz0TxgcS5QTvv-XxhVFydB7u7kS5VMrTRo7gfRpgd7AFs/w640-h512/Screenshot%202024-12-18%20220029.png&quot; width=&quot;640&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;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; color: #e69138; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixIB9XWptK2t0CkoZ4eePqw0KS19y8SOBfZH73ZU1ehwV3fQP89h3DCU8Lb5ZHFvlYOY8AK_hNNctmYDjaXC9NcG8ya4Yw_oXRmBwyvLvzPOjeo1eMoV3acq4kZ1mHa4t0UXP6pmRTACvkIA2f95UcMy7AQ3aucU-Jy4frmZXkkbO-cJvs0F2jfH7jSBI/s803/Screenshot%202024-12-18%20220302.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;441&quot; data-original-width=&quot;803&quot; height=&quot;352&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixIB9XWptK2t0CkoZ4eePqw0KS19y8SOBfZH73ZU1ehwV3fQP89h3DCU8Lb5ZHFvlYOY8AK_hNNctmYDjaXC9NcG8ya4Yw_oXRmBwyvLvzPOjeo1eMoV3acq4kZ1mHa4t0UXP6pmRTACvkIA2f95UcMy7AQ3aucU-Jy4frmZXkkbO-cJvs0F2jfH7jSBI/w640-h352/Screenshot%202024-12-18%20220302.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; color: #e69138; text-align: center;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3 style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Summary&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;We have explored UUID v7 feature in .NET 9and its advantages of inbuilt timestamp which can be really helpful to order created UUIDs in database level.&amp;nbsp;&lt;/span&gt;So, lets start use in our project and get benefitted.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span&gt;Stay tuned for more articles. Thanks for reading!!&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/1908847720740535768/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2024/12/uuid-v7-in-net-9.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/1908847720740535768'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/1908847720740535768'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2024/12/uuid-v7-in-net-9.html' title='UUID v7 in .NET 9'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/AVvXsEhyviFHMuA_2JQrmFpn1j9gsYmyR84_8r4tI586G_ZekfDVhF9TwH1SCRf6TOovHEh8bv4k13ae1XlE-VtRP_GvvGa0xwX9GGpHG5QdIsI9_Ro8fFmueQAJqGy0T6tv6XSdPYvbiGcM3lPptlJz0TxgcS5QTvv-XxhVFydB7u7kS5VMrTRo7gfRpgd7AFs/s72-w640-h512-c/Screenshot%202024-12-18%20220029.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-3487221213435341879</id><published>2024-12-16T21:21:00.001+05:30</published><updated>2024-12-29T20:35:48.976+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET9"/><category scheme="http://www.blogger.com/atom/ns#" term="Index"/><category scheme="http://www.blogger.com/atom/ns#" term="LINQ"/><title type='text'>.NET 9 Index in LINQ</title><content type='html'>&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;About&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Index is one of feature introduced in .NET LINQ. By using this method, we can easily extract implicit index of IEnumerable.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The other .NET 9 LINQ features are as follows.&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-countby-linq.html&quot; target=&quot;_blank&quot;&gt;.NET 9 CountBy in LINQ&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-aggregateby-linq.html&quot; target=&quot;_blank&quot;&gt;.NET 9 AggregateBy in LINQ&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The Index method returns index and index of an item in following format.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Format: IEnumerable&amp;lt;(int Index, TSource Item)&amp;gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h3&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Scenario&lt;/span&gt;&lt;/h3&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Lets consider to display employee name in list and their respective order.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;h4 style=&quot;background-color: white; color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13.2px; margin: 0px; position: relative;&quot;&gt;&lt;span style=&quot;font-size: xx-small;&quot;&gt;Employee class&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;&lt;span style=&quot;font-size: xx-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: white;&quot;&gt;
&lt;pre&gt;&lt;code style=&quot;background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); display: block; overflow: auto; padding: 20px;&quot;&gt;public class Employee
{
    public int Id { get; set; }
    public string Name { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;
  &lt;div style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h4 style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: x-small; margin: 0px; position: relative;&quot;&gt;Setup Employee List with Sample Data&lt;/h4&gt;&lt;div&gt;&lt;pre&gt;&lt;code style=&quot;background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); display: block; overflow: auto; padding: 20px;&quot;&gt;var employees = new List&lt;employee&gt; {
  new Employee(){ Id = 11, Name = &quot;Ram&quot; },
  new Employee(){ Id = 12, Name = &quot;Bheem&quot; },
  new Employee(){Id = 13, Name = &quot;Lakshman&quot;},
  new Employee(){Id = 14, Name = &quot;Hanu&quot;},
  new Employee(){Id = 15, Name = &quot;Dev&quot;},
  new Employee(){Id = 16, Name = &quot;Nandan&quot;},
  new Employee(){Id = 17, Name = &quot;Krish&quot;},
  new Employee(){Id = 18, Name = &quot;Hash&quot;},
};

  foreach ((int index, Employee emp) in employees.Index())
  {
      Console.WriteLine($&quot;Index: {index}, Employee Name: {emp.Name}&quot;);
  }
  &lt;/employee&gt;&lt;/code&gt;&lt;/pre&gt;  
  
  &lt;div style=&quot;color: #222222; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #e69138; font-family: &amp;quot;Times New Roman&amp;quot;; font-size: large;&quot;&gt;Screenshots&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138; font-size: medium;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;The following code and output screenshots gives easy understanding and for your implementation.&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #e69138; font-size: x-small;&quot;&gt;&lt;b&gt;Code&lt;/b&gt;&lt;/span&gt;&lt;/h4&gt;&lt;div style=&quot;color: #222222;&quot;&gt;&lt;span style=&quot;color: #e69138; font-size: medium;&quot;&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/a/AVvXsEgOAk9wiucuzQ-v_XerQ1bPuqoTk6bArHaAw5qksv50bbgfGM3yjLgILtUPBAQndxf0PcRERZZmXUWgclrdyJEnfQlrhFxuq8N3Wqtq0Jh6AANT9hbp-OW4zCxK-C74N-hN3gZJhPJ_kdDYUfQ1MQ_B9WeNkSd3SRxOUo4J49XdCp22XkXy7nPqQMQB8fs&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;332&quot; data-original-width=&quot;582&quot; height=&quot;366&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgOAk9wiucuzQ-v_XerQ1bPuqoTk6bArHaAw5qksv50bbgfGM3yjLgILtUPBAQndxf0PcRERZZmXUWgclrdyJEnfQlrhFxuq8N3Wqtq0Jh6AANT9hbp-OW4zCxK-C74N-hN3gZJhPJ_kdDYUfQ1MQ_B9WeNkSd3SRxOUo4J49XdCp22XkXy7nPqQMQB8fs=w640-h366&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif;&quot;&gt;&lt;h4 style=&quot;color: black; font-size: medium;&quot;&gt;&lt;span style=&quot;color: #e69138; font-size: x-small;&quot;&gt;Output&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138; font-size: x-small;&quot;&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/a/AVvXsEgYHewsTZm1-fn0DdjNZ4_uysMpb7T-qoXWebc3BSIPFxBphDc7xVPdzVGYYV8qAklTnkHy5hmxG95VEx---1IqWkEXL-0pLhcqcbo14TF1uvdVAgb3SwXMXCIzKD-TARJ8ud85sZhFKnG9rgiQaFP72geFrHyEyyb-UKZhEY9kPjwH89QUhrw71XP93IE&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;418&quot; data-original-width=&quot;734&quot; height=&quot;364&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgYHewsTZm1-fn0DdjNZ4_uysMpb7T-qoXWebc3BSIPFxBphDc7xVPdzVGYYV8qAklTnkHy5hmxG95VEx---1IqWkEXL-0pLhcqcbo14TF1uvdVAgb3SwXMXCIzKD-TARJ8ud85sZhFKnG9rgiQaFP72geFrHyEyyb-UKZhEY9kPjwH89QUhrw71XP93IE=w640-h364&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;/span&gt;&lt;h3 style=&quot;color: #222222; margin: 0px; position: relative;&quot;&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;h3 style=&quot;color: #222222; margin: 0px; position: relative;&quot;&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Summary&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;color: #222222;&quot;&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;span style=&quot;font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: small;&quot;&gt;This post explored about Index feature in LINQ introduced in .NET9.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: small;&quot;&gt;Thanks for reading this and stay tuned for more articles.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;color: #222222; font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #e69138; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/3487221213435341879/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2024/12/net-9-index-in-linq.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/3487221213435341879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/3487221213435341879'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2024/12/net-9-index-in-linq.html' title='.NET 9 Index in LINQ'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/a/AVvXsEgOAk9wiucuzQ-v_XerQ1bPuqoTk6bArHaAw5qksv50bbgfGM3yjLgILtUPBAQndxf0PcRERZZmXUWgclrdyJEnfQlrhFxuq8N3Wqtq0Jh6AANT9hbp-OW4zCxK-C74N-hN3gZJhPJ_kdDYUfQ1MQ_B9WeNkSd3SRxOUo4J49XdCp22XkXy7nPqQMQB8fs=s72-w640-h366-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-1853137696317594261</id><published>2024-12-15T19:47:00.006+05:30</published><updated>2024-12-29T20:46:47.335+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET9"/><category scheme="http://www.blogger.com/atom/ns#" term="AggregateBy"/><category scheme="http://www.blogger.com/atom/ns#" term="LINQ"/><title type='text'>.NET 9 AggregateBy LINQ</title><content type='html'>&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&amp;nbsp;About&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;In this post, we are exploring about AggregateBy LINQ method introduced in .NET 9. This is very helpful and being used in scenarios of aggregate operations such as sum, average and grouping of data based on custom conditions.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;In Earlier post, Please look into about other feature discussed about &lt;a href=&quot;https://ramchandr.blogspot.com/2024/12/net-9-countby-linq.html&quot; target=&quot;_blank&quot;&gt;CountBy in LINQ 9&lt;/a&gt;.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So, Lets go ahead to discuss/understand about AggregateBy in LINQ.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Scenario&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;Lets consider following scenario and understand implementation of this before and after .NET 9 approach.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&quot;Get sum of employee merit score points based on job level&quot;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h4 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: xx-small;&quot;&gt;Employee class&lt;/span&gt;&lt;/h4&gt;&lt;div&gt;
&lt;pre&gt;&lt;code style=&quot;background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); display: block; overflow: auto; padding: 20px;&quot;&gt;public class Employee
{
    public int Id { get; set; }
    public string Name { get; set; }
    public int YearJoin { get; set; }
    public int JobLevel { get; set; }
    public int MeritPoints { get; set; }
}
&lt;/code&gt;&lt;/pre&gt;
  &lt;div style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;h4 style=&quot;font-size: x-small; text-align: left;&quot;&gt;Setup Employee List with Sample Data&lt;/h4&gt;&lt;div style=&quot;font-size: x-small;&quot;&gt;&lt;pre&gt;&lt;code style=&quot;background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); display: block; overflow: auto; padding: 20px;&quot;&gt;  var employees = new List&lt;employee&gt; {
  new Employee(){ Id = 11, Name = &quot;Ram&quot;, YearJoin = 2015, JobLevel = 6, MeritPoints = 10 },
  new Employee(){ Id = 12, Name = &quot;Bheem&quot;, YearJoin = 2012, JobLevel = 5, MeritPoints = 20 },
  new Employee(){Id = 13, Name = &quot;Lakshman&quot;, YearJoin = 2015, JobLevel = 6, MeritPoints = 30},
  new Employee(){Id = 14, Name = &quot;Hanu&quot;, YearJoin = 2016, JobLevel = 6, MeritPoints = 40},
  new Employee(){Id = 15, Name = &quot;Dev&quot;, YearJoin = 2024, JobLevel = 6, MeritPoints = 50},
  new Employee(){Id = 16, Name = &quot;Nandan&quot;, YearJoin = 2012, JobLevel = 5, MeritPoints = 60},
  new Employee(){Id = 17, Name = &quot;Krish&quot;, YearJoin = 2012, JobLevel = 5, MeritPoints = 70},
  new Employee(){Id = 18, Name = &quot;Hash&quot;, YearJoin = 2015, JobLevel = 6, MeritPoints = 80},
};&lt;/employee&gt;&lt;/code&gt;&lt;/pre&gt;
  &lt;/div&gt;&lt;div style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;color: #e69138; font-size: medium;&quot;&gt;Before .NET 9&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138; font-size: small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code style=&quot;background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); display: block; overflow: auto; padding: 20px;&quot;&gt;//BEFORE .NET 9 Example
// Aggregate MeritPoints by Job Level using GroupBy and Aggregate
var meritPointsByEmpJobLevel = employees
    .GroupBy(user =&amp;gt; user.JobLevel) // Group users by their Job Level
    .Select(group =&amp;gt; new
    {
        JobLevel = group.Key,
        TotalMeritPoints = group.Sum(user =&amp;gt; user.MeritPoints)
    }
            ); // Aggregate Merit Points for each Job Level
// Print the results
foreach (var jobLevelAggregate in meritPointsByEmpJobLevel)
{
    Console.WriteLine($&quot;Total merit points per each employee level &quot; +
        $&quot;{jobLevelAggregate.JobLevel} is {jobLevelAggregate.TotalMeritPoints}&quot;);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Aforesaid code example, we did the following steps.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;1. Group the employees based on Job level.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;2. Select the Job level as Key and Sum of Meri points on respective job level.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;3. Display the results in fore ach loop based on select results.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #e69138; font-size: small;&quot;&gt;.NET 9&lt;/span&gt;&lt;/h3&gt;
&lt;pre&gt;&lt;code style=&quot;background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); display: block; overflow: auto; padding: 20px;&quot;&gt;var totalEmpMeritPointsByLevel = employees.AggregateBy(e =&amp;gt; e.JobLevel, 
                                    seed: 0, (acc, meritPoints) =&amp;gt; acc + meritPoints.MeritPoints);
foreach (var meritPointByLevel in totalEmpMeritPointsByLevel)
{
    Console.WriteLine($&quot;Total merit points per each employee level &quot; +
        $&quot;{meritPointByLevel.Key} is {meritPointByLevel.Value}&quot;);
}&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;The aforesaid .NET 9 code example, we achieved all in one go with AggregateBy example. The code also very clean and crsip.&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;Syntax:&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;

&lt;pre&gt;&lt;code style=&quot;background-color: #eeeeee; border: 1px solid rgb(153, 153, 153); display: block; overflow: auto; padding: 20px;&quot;&gt;IEnumerable&amp;lt;(TKey Key, TAccumulate Aggregate)&amp;gt; AggregateBy&lt;tsource taccumulate=&quot;&quot; tkey=&quot;&quot;&gt;(
    this IEnumerable&lt;tsource&gt; source,
    Func&lt;tsource tkey=&quot;&quot;&gt; keySelector,
    Func&lt;taccumulate&gt; seedFactory,
    Func&lt;taccumulate taccumulate=&quot;&quot; tsource=&quot;&quot;&gt; aggregator
);
&lt;/taccumulate&gt;&lt;/taccumulate&gt;&lt;/tsource&gt;&lt;/tsource&gt;&lt;/tsource&gt;&lt;/code&gt;&lt;/pre&gt;

    &lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Screenshots&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;Code&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&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/a/AVvXsEjsX4p-Lva8Wj6VIGhmhBlRmjs8C3MuzpGCk4XfmOXOxfLnTtcZ1h31RwmGah5gk2u2dlgUdHzP1PyvIR1FiXdYw4Yyn0zu5SvWbyvo_e-LKxoDiXPJnOZT_wb6_Jw1GH9awk1YJR85nJMW4gZ68xIcCXWOEHPOhYdb8mLf4bESwus83t13cb7fkWfVQc0&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;741&quot; data-original-width=&quot;795&quot; height=&quot;598&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEjsX4p-Lva8Wj6VIGhmhBlRmjs8C3MuzpGCk4XfmOXOxfLnTtcZ1h31RwmGah5gk2u2dlgUdHzP1PyvIR1FiXdYw4Yyn0zu5SvWbyvo_e-LKxoDiXPJnOZT_wb6_Jw1GH9awk1YJR85nJMW4gZ68xIcCXWOEHPOhYdb8mLf4bESwus83t13cb7fkWfVQc0=w640-h598&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Output&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&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/a/AVvXsEhWRxrKh5Ruk1sIM-9VgpDnN8b39YGvbT8WGLBgWWR9ex_zk1JGDInHprozmJMVToEadyAjemG-RcvcwQW30DxZ0ibu5GCMZUnnBviTvIRb2_gB4d0d1x7WItoyjs7JIKRW_-DRUlQdU79zTAR702idayxtLnO4O-G4PYJ5TaRlNu0X9MA3rxwgNo4aNmw&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;302&quot; data-original-width=&quot;1088&quot; height=&quot;178&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEhWRxrKh5Ruk1sIM-9VgpDnN8b39YGvbT8WGLBgWWR9ex_zk1JGDInHprozmJMVToEadyAjemG-RcvcwQW30DxZ0ibu5GCMZUnnBviTvIRb2_gB4d0d1x7WItoyjs7JIKRW_-DRUlQdU79zTAR702idayxtLnO4O-G4PYJ5TaRlNu0X9MA3rxwgNo4aNmw=w640-h178&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h3 style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;Summary&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;color: #e69138;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;In this post, we explored about AggregateBy LINQ feature with ease of use and code examples. Those are really helpful to improve developer productivity and ease of understanding and performance of applications.&lt;/div&gt;&lt;div&gt;Thanks for reading and Stay tuned for more articles!!&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/1853137696317594261/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2024/12/net-9-aggregateby-linq.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/1853137696317594261'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/1853137696317594261'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2024/12/net-9-aggregateby-linq.html' title='.NET 9 AggregateBy LINQ'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/a/AVvXsEjsX4p-Lva8Wj6VIGhmhBlRmjs8C3MuzpGCk4XfmOXOxfLnTtcZ1h31RwmGah5gk2u2dlgUdHzP1PyvIR1FiXdYw4Yyn0zu5SvWbyvo_e-LKxoDiXPJnOZT_wb6_Jw1GH9awk1YJR85nJMW4gZ68xIcCXWOEHPOhYdb8mLf4bESwus83t13cb7fkWfVQc0=s72-w640-h598-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-1642506065046476352</id><published>2024-12-10T21:43:00.001+05:30</published><updated>2024-12-10T21:44:42.016+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term=".NET9"/><category scheme="http://www.blogger.com/atom/ns#" term="CountBy"/><category scheme="http://www.blogger.com/atom/ns#" term="LINQ"/><title type='text'>.NET 9 CountBy LINQ</title><content type='html'>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: #e69138; font-size: medium;&quot;&gt;Introduction&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;.NET 9 is the latest version of Microsoft&#39;s released in Nov 2024. Its open-source development platform for building applications for web, mobile, desktop and cloud environments.&amp;nbsp;&lt;/p&gt;&lt;p&gt;This release is pack of many new features, LINQ methods and performance improvements and many more.&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: #e69138; font-size: medium;&quot;&gt;About&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;In this post, we are focusing about one of new LINQ method introduced in .NET 9. Its very useful, comprehensive and easily can understand and can be used in our project as well :).&lt;/p&gt;&lt;p&gt;So, Lets start explore on this.&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: #e69138; font-size: medium;&quot;&gt;Scenario&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Lets consider a easy scenario as &quot;To get employees count based on the year joined&quot;.&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Employee Class:&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;public class Employee&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; public int Id { get; set; }&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; public string Name { get; set; }&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; public int YearJoin { get; set; }&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Setup Employee List with Sample Data&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &lt;span style=&quot;font-size: x-small;&quot;&gt;var employees = new List&amp;lt;Employee&amp;gt; {&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; new Employee(){ Id = 11, Name = &quot;Ram&quot;, YearJoin = 2015 },&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; new Employee(){ Id = 12, Name = &quot;Bheem&quot;, YearJoin = 2012 },&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; new Employee(){ Id = 13, Name = &quot;Lakshman&quot;, YearJoin = 2015 },&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; new Employee(){ Id = 14, Name = &quot;Hanu&quot;, YearJoin = 2016 },&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; new Employee(){ Id = 15, Name = &quot;Dev&quot;, YearJoin = 2024 },&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; new Employee(){ Id = 16, Name = &quot;Nandan&quot;, YearJoin = 2012 },&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; new Employee(){ Id = 17, Name = &quot;Krish&quot;, YearJoin = 2012 },&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; new Employee(){ Id = 18, Name = &quot;Hash&quot;, YearJoin = 2015 },&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;};&lt;/span&gt;&lt;/p&gt;&lt;p&gt;So, First let us understand - How we are doing currently (Earlier to .NET 9).&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: #e69138; font-size: medium;&quot;&gt;Before .NET 9&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;Approach is - Grouping and Counting&lt;/p&gt;&lt;p&gt;1. &lt;b&gt;GroupBy&lt;/b&gt;: Groups the employees based on their value provided (Year).&lt;/p&gt;&lt;p&gt;2. &lt;b&gt;Select(g =&amp;gt; new {Key = g.Key, Value = g.Count()}}&lt;/b&gt;: project each group into anonymous object with two properties.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;b&gt;Key&lt;/b&gt;: The year joined.&lt;/li&gt;&lt;li&gt;&lt;b&gt;Value&lt;/b&gt;: The count of occurrences of employees in the group.&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Sample Code:&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;var empOccurences = employees&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .GroupBy(c =&amp;gt; c.YearJoin)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .Select(g =&amp;gt; new { g.Key, Value = g.Count() });&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;foreach (var empInfo in empOccurences)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; Console.WriteLine($&quot;There are {empInfo.Value} users with the year joined {empInfo.Key}&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: #e69138; font-size: medium;&quot;&gt;.NET 9&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;In .NET 9 -Its simplifies the process and streamlined code like below.&lt;/p&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;foreach (var empCount in employees.CountBy(user =&amp;gt; user.YearJoin))&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&amp;nbsp; &amp;nbsp; Console.WriteLine($&quot;There are {empInfo.Value} users with the year joined {empInfo.Key}&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;color: #e69138; font-size: medium;&quot;&gt;Screenshots&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Code&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&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/a/AVvXsEgt5HoopuMF1Ip66zMmV1exLNVxT8CGh8s-Qz0acxc0xiB4eIRdXUCbpY_uwKbYcoI0-LQMLoZ6EAU9iP5UrtoeoqL22T8GRkCa_8-MgGQFRBG2GkyE2TaxhSspB2mIk2MtcP9XpG4JXcLQrQLYYsKbIKnvPmABIS9esrcJwRVvW8WTVFc_ciGoH5ly6MI&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;581&quot; data-original-width=&quot;799&quot; height=&quot;466&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgt5HoopuMF1Ip66zMmV1exLNVxT8CGh8s-Qz0acxc0xiB4eIRdXUCbpY_uwKbYcoI0-LQMLoZ6EAU9iP5UrtoeoqL22T8GRkCa_8-MgGQFRBG2GkyE2TaxhSspB2mIk2MtcP9XpG4JXcLQrQLYYsKbIKnvPmABIS9esrcJwRVvW8WTVFc_ciGoH5ly6MI=w604-h466&quot; width=&quot;604&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;Output&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&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/a/AVvXsEgvfzJASSilraXT8Chij0htljSyXTi6S9Gm2ZrWqsmZi6ofJDzdLFJ0RgMxUfhSo2ZHeIWGMOTQ2H4d-Wko621mFThJKw_lFDxOfJXzRm-i_PLWKkK2PHw4_JqPUw0KoZM3lp-YGHPCfirvJfHdiUpnqmTIjcNbAreew3GgOOUbipFpy9JpLXRpFdkiX4o&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img alt=&quot;&quot; data-original-height=&quot;469&quot; data-original-width=&quot;976&quot; height=&quot;193&quot; src=&quot;https://blogger.googleusercontent.com/img/a/AVvXsEgvfzJASSilraXT8Chij0htljSyXTi6S9Gm2ZrWqsmZi6ofJDzdLFJ0RgMxUfhSo2ZHeIWGMOTQ2H4d-Wko621mFThJKw_lFDxOfJXzRm-i_PLWKkK2PHw4_JqPUw0KoZM3lp-YGHPCfirvJfHdiUpnqmTIjcNbAreew3GgOOUbipFpy9JpLXRpFdkiX4o=w400-h193&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;p&gt;&lt;b&gt;&lt;span style=&quot;color: #e69138; font-size: medium;&quot;&gt;CountBy Benefits&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;Simplifies the code hence it improves readability and developer productivity.&lt;/li&gt;&lt;li&gt;Optimizes the performance by streamlining the grouping and counting process.&lt;/li&gt;&lt;li&gt;It makes data aggregation makes more efficient and concise.&amp;nbsp;&lt;/li&gt;&lt;/ul&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I will come up with another LINQ method introduced in .NET 9 in upcoming post. Stay tuned!!&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Thanks for your reading and provide your comments and suggestions as always.&lt;/div&gt;&lt;p&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/1642506065046476352/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2024/12/net-9-countby-linq.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/1642506065046476352'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/1642506065046476352'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2024/12/net-9-countby-linq.html' title='.NET 9 CountBy LINQ'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/a/AVvXsEgt5HoopuMF1Ip66zMmV1exLNVxT8CGh8s-Qz0acxc0xiB4eIRdXUCbpY_uwKbYcoI0-LQMLoZ6EAU9iP5UrtoeoqL22T8GRkCa_8-MgGQFRBG2GkyE2TaxhSspB2mIk2MtcP9XpG4JXcLQrQLYYsKbIKnvPmABIS9esrcJwRVvW8WTVFc_ciGoH5ly6MI=s72-w604-h466-c" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-6537065703712880422</id><published>2015-01-12T15:43:00.001+05:30</published><updated>2015-01-12T16:41:56.555+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="AngularJS"/><title type='text'>AngularJS Core Directives: Include, Click and Repeat</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;About&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
This article provides an idea of some more directives like ng-include, ng-click and ng-repeat in AngularJs.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
This article is just a continuation of my previous article about &lt;a href=&quot;http://ramchandr.blogspot.com/2015/01/quick-start-of-angularjs.html&quot; rollapp-href=&quot;http://ramchandr.blogspot.com/2015/01/quick-start-of-angularjs.html&quot; target=&quot;_blank&quot; title=&quot;Quick Start On AngularJS&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Quick Start Of AngularJS&lt;/span&gt;&lt;/a&gt;. So, please read that to get the initial/basic idea of AngularJS.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;ng-include&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
This is an AngularJS directive, it is very helpful to include the various files in a main page using the ng-include attribute. &lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
For
 example, you have one page layout that contains a header, body, footer 
and so on. In that scenario, you can create various HTML files for a 
header and footer then you can include those in the main HTML file. 
Because of this implementation the page looks cleaner and the 
code/design is also separated.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;Sample Application&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
The header.html file contains the following.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;&lt;div style=&quot;border: 5px solid gray; text-align: center; width: 100%;&quot;&gt;
Header of the site  
&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
The footer HTML file contains the following.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;&lt;div style=&quot;border: 5px solid gray; text-align: center; width: 100%;&quot;&gt;
Copyright Ramchand @2014  
&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
The main index.html file contains the following.&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&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/AVvXsEjOGXIIl-KICoQ8YIeTiMZjYivGOQbgiBWXgEdXfEFWzzhtIMPotSTh23t03e6StgYtXRy-niNUEgIesOamPOo10SPT1H-Ksu7en2Wy0KMPt5cMMSfLA-00jUSVNatvyyp-G2Y2D5Y2PGk/s1600/01-AngularJS-Include-index.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOGXIIl-KICoQ8YIeTiMZjYivGOQbgiBWXgEdXfEFWzzhtIMPotSTh23t03e6StgYtXRy-niNUEgIesOamPOo10SPT1H-Ksu7en2Wy0KMPt5cMMSfLA-00jUSVNatvyyp-G2Y2D5Y2PGk/s1600/01-AngularJS-Include-index.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOGXIIl-KICoQ8YIeTiMZjYivGOQbgiBWXgEdXfEFWzzhtIMPotSTh23t03e6StgYtXRy-niNUEgIesOamPOo10SPT1H-Ksu7en2Wy0KMPt5cMMSfLA-00jUSVNatvyyp-G2Y2D5Y2PGk/s1600/01-AngularJS-Include-index.jpg&quot; height=&quot;330&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
The previous index.html contains the ng-include attributes for header 
and footer divs with the respective HTML file path values that should be
 specified in single quotes. 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
Now, when you run the index.html file, the output looks as in the following.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&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/AVvXsEgidEm4ThfmKrwOLoQdtuUDQA85W-DO9I-wlYpfJUkCNenLUek0hZE7SRaF8MkcSk-qTL-v_QIaALqAB4xgWSFIZKGpvHeWen20uNaU_MQxjxc_GL5lfSphlQF_BzGJrlVxHHcnY4-pBdQ/s1600/02-AngularJS-Include-output.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgidEm4ThfmKrwOLoQdtuUDQA85W-DO9I-wlYpfJUkCNenLUek0hZE7SRaF8MkcSk-qTL-v_QIaALqAB4xgWSFIZKGpvHeWen20uNaU_MQxjxc_GL5lfSphlQF_BzGJrlVxHHcnY4-pBdQ/s1600/02-AngularJS-Include-output.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgidEm4ThfmKrwOLoQdtuUDQA85W-DO9I-wlYpfJUkCNenLUek0hZE7SRaF8MkcSk-qTL-v_QIaALqAB4xgWSFIZKGpvHeWen20uNaU_MQxjxc_GL5lfSphlQF_BzGJrlVxHHcnY4-pBdQ/s1600/02-AngularJS-Include-output.jpg&quot; height=&quot;192&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;div&gt;
You can run the application using Plunker tool at&amp;nbsp; &lt;a href=&quot;http://plnkr.co/edit/CRzHHFTE0CbgymWrDHyY?p=preview&quot; rollapp-href=&quot;http://plnkr.co/edit/CRzHHFTE0CbgymWrDHyY?p=preview&quot; target=&quot;_blank&quot; title=&quot;AngularJS include&quot;&gt;AngularJS include&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;ng-click&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
This
 is also one of the directives, you can use this in one of the scenarios
 like when you click on a button if you do any operation then this would
 be useful. &lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;Scenario:&lt;/b&gt;
 The form contains an input text box and Search button, whenever the 
user enters a value into a text box and clicks on the search button you 
need to display the user-entered value, if the user clicks on the search
 button without entering anything then we need to display a message.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
The index.html file looks as in the following.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&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/AVvXsEii_wE3PzTypQTBurNk1PRBpj7jLnlNTnMaouUaf6Z18Y3XgvOGvfkwkhHnITCLdm2OQFLoXCKNbLSZCZd9LoNGSCRSacy1wPPYYgVMujykgielOxiSE_-F6Mg8RVCmJAq2nBCrEwQH2ao/s1600/03-AngularJS-Click-index.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii_wE3PzTypQTBurNk1PRBpj7jLnlNTnMaouUaf6Z18Y3XgvOGvfkwkhHnITCLdm2OQFLoXCKNbLSZCZd9LoNGSCRSacy1wPPYYgVMujykgielOxiSE_-F6Mg8RVCmJAq2nBCrEwQH2ao/s1600/03-AngularJS-Click-index.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii_wE3PzTypQTBurNk1PRBpj7jLnlNTnMaouUaf6Z18Y3XgvOGvfkwkhHnITCLdm2OQFLoXCKNbLSZCZd9LoNGSCRSacy1wPPYYgVMujykgielOxiSE_-F6Mg8RVCmJAq2nBCrEwQH2ao/s1600/03-AngularJS-Click-index.jpg&quot; height=&quot;404&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&amp;nbsp;The DemoClick.js file contains the following lines of JavaScript code.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;pre class=&quot;JS&quot; name=&quot;code&quot;&gt;(function() {  
  var app = angular.module(&quot;DemoClickApp&quot;, []);  
  
  var DemoController = function($scope) {  
    $scope.Search = function(empname) {  
      if (empname)  
        $scope.result = &quot;You have searched for &quot; + empname;  
      else  
        $scope.result = &quot;Please enter employee name&quot;;  
    };  
  };  
  app.controller(&quot;DemoController&quot;, DemoController);  
})();  
&lt;/pre&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&amp;nbsp;Now, when you run the index.html file by default it looks as in the following.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&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/AVvXsEigWdpyRljcv873cWvKwYFwA437i9Kp2lSkkwO6posTj-AzsB9c4a3k4u1KziTlb98qllg6p3ayzII7OIe1FHt67q1oyL_u1HdVm6JpZwU4k6cJS1MFyVig-Kmi3dqV8YSb85pSpQaLWC8/s1600/03-AngularJS-Click-default-1.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigWdpyRljcv873cWvKwYFwA437i9Kp2lSkkwO6posTj-AzsB9c4a3k4u1KziTlb98qllg6p3ayzII7OIe1FHt67q1oyL_u1HdVm6JpZwU4k6cJS1MFyVig-Kmi3dqV8YSb85pSpQaLWC8/s1600/03-AngularJS-Click-default-1.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigWdpyRljcv873cWvKwYFwA437i9Kp2lSkkwO6posTj-AzsB9c4a3k4u1KziTlb98qllg6p3ayzII7OIe1FHt67q1oyL_u1HdVm6JpZwU4k6cJS1MFyVig-Kmi3dqV8YSb85pSpQaLWC8/s1600/03-AngularJS-Click-default-1.jpg&quot; height=&quot;216&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
If you click on the Search button without
 entering any value in the text box then the output screen displays an 
alert kind of message as &quot;Please enter employee name&quot; that looks as in 
the following.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&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/AVvXsEg9LfY7686tWFxfgtxoIRjekMo2n1xKtHBhnkRmtbsezn-yqUxlPt-FhJO5Hf3_pCdVkhjy13zq6iYONYgaIZd-dhFdCD51sPwwLcHmRQ08e9gZhEpOzBr2m0NYhVCMsETDJX7Gs-drXBY/s1600/03-AngularJS-Click-default.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9LfY7686tWFxfgtxoIRjekMo2n1xKtHBhnkRmtbsezn-yqUxlPt-FhJO5Hf3_pCdVkhjy13zq6iYONYgaIZd-dhFdCD51sPwwLcHmRQ08e9gZhEpOzBr2m0NYhVCMsETDJX7Gs-drXBY/s1600/03-AngularJS-Click-default.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9LfY7686tWFxfgtxoIRjekMo2n1xKtHBhnkRmtbsezn-yqUxlPt-FhJO5Hf3_pCdVkhjy13zq6iYONYgaIZd-dhFdCD51sPwwLcHmRQ08e9gZhEpOzBr2m0NYhVCMsETDJX7Gs-drXBY/s1600/03-AngularJS-Click-default.jpg&quot; height=&quot;204&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;Now, you can enter some value into a text box and click on the search box and then the displayed screen is as follows.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&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/AVvXsEg06yhc-TTxpGONyo0PmLCTbeaQ1B-UwysG-8aZILu1roh8l02vn7OsT30rH7-6udp2bbv6GiziG51Fr0n9MKqI_rtZkCUYrnPQRCQH4X9QSGQ9PA3fnK600mozynTfrOqNmKeyWnHDPkc/s1600/03-AngularJS-Click-default-2.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg06yhc-TTxpGONyo0PmLCTbeaQ1B-UwysG-8aZILu1roh8l02vn7OsT30rH7-6udp2bbv6GiziG51Fr0n9MKqI_rtZkCUYrnPQRCQH4X9QSGQ9PA3fnK600mozynTfrOqNmKeyWnHDPkc/s1600/03-AngularJS-Click-default-2.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg06yhc-TTxpGONyo0PmLCTbeaQ1B-UwysG-8aZILu1roh8l02vn7OsT30rH7-6udp2bbv6GiziG51Fr0n9MKqI_rtZkCUYrnPQRCQH4X9QSGQ9PA3fnK600mozynTfrOqNmKeyWnHDPkc/s1600/03-AngularJS-Click-default-2.jpg&quot; height=&quot;206&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div&gt;
You can run the previous discussed example using the Plunker tool at &lt;a href=&quot;http://plnkr.co/edit/podRFsql7wddqZcPScnF?p=preview&quot; rollapp-href=&quot;http://plnkr.co/edit/podRFsql7wddqZcPScnF?p=preview&quot; target=&quot;_blank&quot; title=&quot;AngularJS click&quot;&gt;AngularJS click&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;ng-repeat&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt; &lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
This
 directive is like a foreach loop in C#. By using this directive you can
 display a collection of items in a view (HTML page).&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;b&gt;Scenario:&lt;/b&gt; You can display a list of employees using the ng-repeat directive in AngularJS. &lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;  
&lt;html&gt;  
  
&lt;head&gt;  
  &lt;!-- 1. Angular JS Script CDN reference added  --&gt;  
  &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js&quot;&gt;  
  &lt;/script&gt;  
  &lt;!-- 2. Script JS Reference --&gt;  
  &lt;script src=&quot;Employee.js&quot;&gt;&lt;/script&gt;  
&lt;/head&gt;  
&lt;!-- 3. ng-app directive included --&gt;  
  
&lt;body ng-app=&quot;DemoRepeatApp&quot;&gt;  
  &lt;h1&gt;
List of Emplooyees&lt;/h1&gt;
&lt;!-- 4. ng-controller directive included --&gt;  
  &lt;form ng-controller=&quot;DemoController&quot;&gt;
  
    &lt;table&gt;  
      &lt;thead&gt;
&lt;tr&gt;  
          &lt;th&gt;Name&lt;/th&gt;  
          &lt;th&gt;Designation&lt;/th&gt;  
          &lt;th&gt;Location&lt;/th&gt;  
        &lt;/tr&gt;
&lt;/thead&gt;  
      &lt;tbody&gt;  
      &lt;!-- 5. ng-repeat directive included --&gt;
&lt;tr ng-repeat=&quot;emp in employees&quot;&gt;  
          &lt;td&gt;{{emp.Name}}&lt;/td&gt;  
          &lt;td&gt;{{emp.Designation}}&lt;/td&gt;  
          &lt;td&gt;{{emp.Location}}&lt;/td&gt;  
        &lt;/tr&gt;
&lt;/tbody&gt;  
    &lt;/table&gt;
&lt;/form&gt;
&lt;/body&gt;  
  
&lt;/html&gt; 
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
The previous HTML file is self explanatory since it contains 
point-by-point details in comments format. The fifth point&amp;nbsp;is that&amp;nbsp;you 
have added something as a ng-repeat attribute with the value of &quot;emp in 
employees&quot;. Here &quot;employees&quot; is the collection value that is obtained 
from the Employee.JS controller. &lt;br /&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
The Employee.js contains the following lines of JavaScript code.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;JS&quot; name=&quot;code&quot;&gt;(function() {  
  var app = angular.module(&quot;DemoRepeatApp&quot;, []);  
  
  var DemoController = function($scope) {  
    var sampleEmployees = &#39;[&#39; +  
      &#39;{ &quot;Name&quot;:&quot;Ramchand&quot; , &quot;Designation&quot;:&quot;SSE&quot; , &quot;Location&quot;:&quot;Bhubhaneswar&quot; },&#39; +  
      &#39;{ &quot;Name&quot;:&quot;Lakshman&quot; , &quot;Designation&quot;:&quot;DBA&quot; , &quot;Location&quot;:&quot;Noida&quot; },&#39; +  
      &#39;{ &quot;Name&quot;:&quot;ABC&quot; , &quot;Designation&quot;:&quot;Team Lead&quot; , &quot;Location&quot;:&quot;Banglore&quot; } ]&#39;;  
    $scope.employees = JSON.parse(sampleEmployees);  
  };  
  app.controller(&quot;DemoController&quot;, DemoController);  
})();
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
The following describes the Employee.js file:&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;ol&gt;
&lt;li&gt;Angular module created with the name DemoRepeatApp.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;The variable DemoController is assigned for the Controller action.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;The Controller contains a variable named &quot;sampleEmployees&quot; that contains a list of sample employess in JSON format.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;Assign the JSON converted sample employees list to the $scope.employees object.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div&gt;
Now, you can run the index.html file and then the output will be displayed as in the following.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&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/AVvXsEgJ7dX0-Xzm0JZ7odAKdQ21oyfvJ06forGGTIEFcd_Z9HkwmJ3uf_gXh-d1ynxuRdkVxRc-IXnLfVJCg9nGAeaPwWxO9vL1RF6X98A7wmNxhNGNsUqflq_fN2OIVdzJH8Sl1z2FUXnCkhE/s1600/06-AngularJS-Repeat-output.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJ7dX0-Xzm0JZ7odAKdQ21oyfvJ06forGGTIEFcd_Z9HkwmJ3uf_gXh-d1ynxuRdkVxRc-IXnLfVJCg9nGAeaPwWxO9vL1RF6X98A7wmNxhNGNsUqflq_fN2OIVdzJH8Sl1z2FUXnCkhE/s1600/06-AngularJS-Repeat-output.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgJ7dX0-Xzm0JZ7odAKdQ21oyfvJ06forGGTIEFcd_Z9HkwmJ3uf_gXh-d1ynxuRdkVxRc-IXnLfVJCg9nGAeaPwWxO9vL1RF6X98A7wmNxhNGNsUqflq_fN2OIVdzJH8Sl1z2FUXnCkhE/s1600/06-AngularJS-Repeat-output.jpg&quot; height=&quot;238&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
You can run the previous example using Plunker at&amp;nbsp;&lt;a href=&quot;http://plnkr.co/edit/nkCVZ2JXY7P9ARrK5twu?p=preview&quot; rollapp-href=&quot;http://plnkr.co/edit/nkCVZ2JXY7P9ARrK5twu?p=preview&quot; target=&quot;_blank&quot; title=&quot;AngularJS Repeat&quot;&gt;AngularJS Repeat&lt;/a&gt; .&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
You can download the aforesaid examples at&amp;nbsp;&lt;a href=&quot;http://goo.gl/gyr3Er&quot; rollapp-href=&quot;http://goo.gl/gyr3Er&quot; target=&quot;_blank&quot;&gt;AngularJS Directives&lt;/a&gt; &lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;Conclusion&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
This article provided an idea of core directives of ng-include, ng-click and ng-repeat in AngularJS. &lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div id=&quot;raIcons&quot; style=&quot;display: none;&quot;&gt;
&lt;img class=&quot;raImg&quot; height=&quot;32&quot; src=&quot;https://dfsuknfbz46oq.cloudfront.net/p/icons/kolourpaint.png&quot; width=&quot;32&quot; /&gt;&lt;br /&gt;
&lt;img class=&quot;raImg&quot; height=&quot;32&quot; src=&quot;https://dfsuknfbz46oq.cloudfront.net/p/icons/kolourpaint.png&quot; width=&quot;32&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/6537065703712880422/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2015/01/angularjs-core-directives-include-click.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/6537065703712880422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/6537065703712880422'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2015/01/angularjs-core-directives-include-click.html' title='AngularJS Core Directives: Include, Click and Repeat'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/AVvXsEjOGXIIl-KICoQ8YIeTiMZjYivGOQbgiBWXgEdXfEFWzzhtIMPotSTh23t03e6StgYtXRy-niNUEgIesOamPOo10SPT1H-Ksu7en2Wy0KMPt5cMMSfLA-00jUSVNatvyyp-G2Y2D5Y2PGk/s72-c/01-AngularJS-Include-index.jpg" height="72" width="72"/><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-6505975645297690415</id><published>2015-01-12T15:22:00.001+05:30</published><updated>2015-01-12T16:33:09.548+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="AngularJS"/><title type='text'>Quick Start Of AngularJS</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div align=&quot;justify&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;About&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; &lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
Angular
 JS is the one of the finest JavaScript frameworks to create dynamic web
 applications by writing less code&amp;nbsp;with an easy syntax in HTML files.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;RoadMap&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
In this article you will get an idea of the following concepts.&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
Introduction&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
Prerequisites&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
Download Angular Js&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
Angular Js Editors&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
Angular Js Architecture&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
About ng-app and Binding Expressions &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
ng-controller&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
ng-model&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
ng-show and ng-hide&amp;nbsp;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Introduction&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
Angular
 JS is the one of the best frontend frameworks for implementing any kind
 of dynamic web application using JavaScript and HTML for the following 
reasons.&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
It helps you to organize your JavaScript code by creating controllers, modules and so on.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
The website creation is very fast, as fast as adding attributes to the controls.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
It is compatible with jQuery as well.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
It&#39;s suitable for testing the application since the way of writing JavaScript is organized.&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
Angular
 JS started as a Google project but now it is an open-source project. So
 it&#39;s available in GitHub and anyone can contribute to it.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
The official site for &lt;a href=&quot;https://angularjs.org/&quot; rollapp-href=&quot;https://angularjs.org/&quot;&gt;Angular JS&lt;/a&gt;.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;Until now, there are many applications developed using Angular JS. You can get a list of all those applications from the URL &lt;a href=&quot;https://builtwith.angularjs.org/&quot; rollapp-href=&quot;https://builtwith.angularjs.org/&quot; target=&quot;_blank&quot;&gt;Buit With AngularJS&lt;/a&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
In Angular JS web applications, using &lt;a href=&quot;https://docs.angularjs.org/api/ng/directive&quot; rollapp-href=&quot;https://docs.angularjs.org/api/ng/directive&quot; target=&quot;_blank&quot;&gt;Directives&lt;/a&gt; you can tell HTML to trigger your JavaScript functions.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
Angular
 JS provides many directives, even though most of the directives are 
understandable by the name itself. The directives start with &lt;b&gt;“ng-”. &lt;/b&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;Here ng refers to&amp;nbsp;and is pronounced as Angular.&lt;/span&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
Angular JS has no other dependencies. So you just need to include the JavaScript file whereever required.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Prerequisites&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
To
 implement web applications using the frontend application framework, 
you just need to have some idea of the following concepts:&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
HTML&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
CSS&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
JavaScript&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Download AngularJS&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;The Angular js files you can download from &lt;a href=&quot;https://angularjs.org/&quot; rollapp-href=&quot;https://angularjs.org/&quot;&gt;AngularJS&lt;/a&gt;. You can even use the CDN URL to access the JavaScript file.&lt;/span&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
The CDN URL is: https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;AngularJS Editors&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
There
 are many suitable editors available (online/offline) to implement or 
practice Angular JS applications. They are the following:&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
&lt;a href=&quot;http://plnkr.co/&quot; rollapp-href=&quot;http://plnkr.co/&quot;&gt;Plunker&lt;/a&gt;.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
&lt;a href=&quot;https://www.jetbrains.com/webstorm/&quot; rollapp-href=&quot;https://www.jetbrains.com/webstorm/&quot;&gt;WebStorm&lt;/a&gt;.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;JS Fiddler (&lt;a href=&quot;http://jsfiddle.net/&quot; rollapp-href=&quot;http://jsfiddle.net/&quot;&gt;JSFiddle&lt;/a&gt; ) and so on.&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;AngularJS Architecture&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
AngualrJS
 should be categorized as pinny needed MV* framework and it also 
supports Unit tests and both integrated end to end tests.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
&lt;b&gt;Model:&lt;/b&gt; the Model is used to restore the data and state of your application.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
&lt;b&gt;View:&lt;/b&gt; Where you actually render to the user the information they want.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
It
 stands like any other Controller / Presenter / ViewModel and so on. 
Even though in most of the cases we will use the controller.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
So,
 Controllers are the main components in Angular applications, Angular JS
 supports two-way binding. That means that whenever the user enters into
 the form fields they are instantly updated in Angular models.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
So, let&#39;s start a sample application using Angular JS to get a brief idea of it.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
&lt;b&gt;Note:&lt;/b&gt;
 in these examples, I am using Angular Js 1.3.8, the latest version, 
since this version contains many features and at the same time, some of 
the features that are supported in 1.2.x would not be supported in the 
1.3.8 version (for example, Global controller functions are not 
supported in 1.3.x by default).&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;ng-app and Binding Expressions&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
In this example, you will implement a basic application using Angular JS.  
  
&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;  
&lt;html&gt;  
  
&lt;head&gt;  
  &lt;!-- 1. Angular JS Script CDN reference added  --&gt;  
  &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js&quot;&gt;  
  &lt;/script&gt;  
&lt;/head&gt;  
  
&lt;body&gt;  
  &lt;h1&gt;
Welcome to Angular Application&lt;/h1&gt;
&lt;!-- 2. ng-app directive added as attribute to the div  --&gt;  
  &lt;div id=&quot;AngularDiv&quot; ng-app=&quot;&quot;&gt;
  
    &lt;!--3. {{ }} Data binding Expressions --&gt;  
    This div is controlled by Angular JS: {{ 1 + 2 }}  
    
  
    &lt;!--4. {{ }} Data binding Expressions with in a single   
    quote treated as constant string --&gt;  
    To Display Constants / Static ones in Angular JS: {{ &#39;1 + 2&#39; }}  
  &lt;/div&gt;
&lt;!-- 5.This is not in the part of Angular JS --&gt;  
  &lt;div id=&quot;NormalDiv&quot;&gt;
  
    Normal div doesn&#39;t handled by Angular JS: {{ 1 + 2 }}  
  &lt;/div&gt;
&lt;/body&gt;  
  
&lt;/html&gt;
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
The previously described HTML file contains five notified points as specified in the comments section of HTML.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
The Angular JS script CDN reference added at the head of HTML file.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
&lt;b&gt;ng-app:&lt;/b&gt;
 The directive ng-app is added as an attribute to one of the div with an
 Id of AngularDiv. It is a special directive since whenever it is found 
inside a HTML page it starts the action of managing the page.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
&lt;b&gt;{{ }}:&lt;/b&gt; This format or notation is called Binding Expressions in Angular JS.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
So,
 whenever you have defined some expression inside the Binding 
Expressions ({{ }}) that is controlled by AngularJS directive (ng-app) 
automatically it evaluates and displays the results in an HTML page.&lt;/div&gt;
&lt;div&gt;
If
 you want to display an expression within binding expressions ( {{ }} ) 
without evaluation then you need to enclose it with single quotes as 
described in the 4&lt;sup&gt;th&lt;/sup&gt; point of the HTML file.&lt;/div&gt;
&lt;div&gt;
The 
other div with the Id NormalDiv does not have an assigned attribute 
(ng-app). So it displays data normally without evaluating the data 
within the binding expressions.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
Now, you can save the HTML file and run it in a browser and the output will be displayed as follows.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&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/AVvXsEggUTnghRAfP1BnyNxJU_7cKx3bvQs6_JG_LawvlOJmiB1MR8BslghemPHBp4E-52eW9PmyQGG1XzZPb3_-EO09ksh8ZdvX-DU8NiVQl4n848KJMoFHFVo9NP8leQ9nb8fKhyphenhyphenGxemJnvww/s1600/01-AngularJs-Starter.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggUTnghRAfP1BnyNxJU_7cKx3bvQs6_JG_LawvlOJmiB1MR8BslghemPHBp4E-52eW9PmyQGG1XzZPb3_-EO09ksh8ZdvX-DU8NiVQl4n848KJMoFHFVo9NP8leQ9nb8fKhyphenhyphenGxemJnvww/s1600/01-AngularJs-Starter.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggUTnghRAfP1BnyNxJU_7cKx3bvQs6_JG_LawvlOJmiB1MR8BslghemPHBp4E-52eW9PmyQGG1XzZPb3_-EO09ksh8ZdvX-DU8NiVQl4n848KJMoFHFVo9NP8leQ9nb8fKhyphenhyphenGxemJnvww/s1600/01-AngularJs-Starter.jpg&quot; height=&quot;224&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
You can run the sample application using the Plnkr tool at&amp;nbsp;&lt;a href=&quot;http://plnkr.co/edit/eMge2QMyEtLgK7G2rNnq?p=preview&quot; rollapp-href=&quot;http://plnkr.co/edit/eMge2QMyEtLgK7G2rNnq?p=preview&quot; target=&quot;_blank&quot; title=&quot;AngularJs Starter&quot;&gt;AngularJs Starter&lt;/a&gt; .&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
Until
 now, you got an idea of the special directive named “ng-app” and how 
you can use the binding expressions to evaluate the data. Now, you can 
move to the next step of writing JavaScript code and trigger that code 
in the HTML file using Angular JS directives.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;ng-controller&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
The
 primary responsibility of the controller is to create the scope object 
and that scope can communicate with the view in both directions. You can
 bind the properties and functions to the scope object.  
  
&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;  
&lt;html&gt;  
  
&lt;head&gt;  
  &lt;!-- 1. Angular JS Script CDN reference added  --&gt;  
  &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js&quot;&gt;  
  &lt;/script&gt;  
  &lt;!-- 2. Script JS Reference --&gt;  
  &lt;script src=&quot;Demo.js&quot;&gt;&lt;/script&gt;  
&lt;/head&gt;  
&lt;!--3. ng-app is DemoApp and controller is DemoController --&gt;  
&lt;body ng-app=&quot;DemoApp&quot;&gt;  
  &lt;h1 ng-controller=&quot;DemoController&quot;&gt;
{{ angularjs }}&lt;/h1&gt;
&lt;/body&gt;  
  
&lt;/html&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
The HTML file contains mainly the following 3 points:&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;Angular Js script file CDN path reference.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;Demo.js file reference containing a few lines of JavaScript code.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;ng-app
 refers to the module name (DemoApp), it refers to any controllers 
created under it that is part of that module. Ng-controller refers to 
the controller name (DemoController).&amp;nbsp; &lt;/li&gt;
&lt;/ol&gt;
The Demo.js file contains the following lines of JavaScript code.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;js&quot; name=&quot;code&quot;&gt;var WelcomeAngular = function($scope) {  
  $scope.angularjs = &quot;Welcome to Angular Js&quot;;  
};  
  
var app = angular.module(&quot;DemoApp&quot;, [])  
app.controller(&#39;DemoController&#39;, WelcomeAngular);
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
The 
first step of JavaScript file contains one variable named 
WelcomeAngular. It refers to one function with the scope object. The 
scope object contains one property named angualrjs.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
In
 the second step you are creating an Angular module named “DemoApp” to 
the variable “app” and then assigning a controller named 
“DemoController” to that app.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
You
 can now run the HTML file and then you will see the output as “Welcome 
to Angular Js” that was specified in the JavaScript file to the property
 named angularjs in the scope object.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
You can run the sample application using the Plnkr tool at&amp;nbsp; &lt;a href=&quot;http://plnkr.co/edit/Sl7IidlLTAI2K1xpohEg?p=preview&quot; rollapp-href=&quot;http://plnkr.co/edit/Sl7IidlLTAI2K1xpohEg?p=preview&quot; target=&quot;_blank&quot; title=&quot;AngularJs Controller&quot;&gt;AngularJs Controller&lt;/a&gt;.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;ng-model&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
ng-model
 is also one of the directives, it can bind to the input, select or 
custom form controls using the property named ng-model.&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;  
&lt;html&gt;  
  
&lt;head&gt;  
  &lt;!-- 1. Angular JS Script CDN reference added  --&gt;  
  &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js&quot;&gt;  
  &lt;/script&gt;  
&lt;/head&gt;  
&lt;!-- 2. ng-app directive included --&gt;  
&lt;body ng-app=&quot;&quot;&gt;  
  &lt;h1&gt;
Employee Search&lt;/h1&gt;
&lt;form&gt;
  
    &lt;label&gt;Employee Name:&lt;/label&gt;  
    &lt;!--3. ng-model directive added to the input field with the value empname  --&gt;  
    &lt;input ng-model=&quot;empname&quot; placeholder=&quot;Employee name to find&quot; type=&quot;text&quot; /&gt;  
    
&lt;pre&gt;You entered employee name is: {{empname}} &lt;/pre&gt;
&lt;/form&gt;
&lt;/body&gt;  
  
&lt;/html&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
Added the Angular JS CDN path.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
ng-app directive was included in the body field. So the HTML body is under Angular JS. &lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
ng-model is added to the input field with the value empname.&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
In
 this example, as you notified the only new one is ng-model with the 
value in the input field. So, whenever you have added the ng-model 
property with the value (empname) and where you are using that value 
(empname) automatically it populates by entering the text into the 
respective input field.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
Initially, when you run the HTML file, it is displayed like the following.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&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/AVvXsEh4Kqsh7RIhzwI_2wf9vKMiINW9TgrixUe7hUwaYtfJB-vTurzGrWpbkmy2QWCOpSq-CO9rhtXDeI6AWzvTua3Wn9yyHPiRSBwGmBNBj6glGubWl5LBGqX_nyLHTxUAdbeNWBCnwzbdtTk/s1600/03-AngularJs-Model-01.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4Kqsh7RIhzwI_2wf9vKMiINW9TgrixUe7hUwaYtfJB-vTurzGrWpbkmy2QWCOpSq-CO9rhtXDeI6AWzvTua3Wn9yyHPiRSBwGmBNBj6glGubWl5LBGqX_nyLHTxUAdbeNWBCnwzbdtTk/s1600/03-AngularJs-Model-01.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh4Kqsh7RIhzwI_2wf9vKMiINW9TgrixUe7hUwaYtfJB-vTurzGrWpbkmy2QWCOpSq-CO9rhtXDeI6AWzvTua3Wn9yyHPiRSBwGmBNBj6glGubWl5LBGqX_nyLHTxUAdbeNWBCnwzbdtTk/s1600/03-AngularJs-Model-01.jpg&quot; height=&quot;224&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now, whenever you have entered some value into the TextBox those values 
are automatically shown in the screen as output asynchronously.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&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/AVvXsEg6HKynDwxIrdcgp9KIbPQkAi3T3jfb2YH9Bg2jdEY6zlfcD0Dic_6Nm7_vX2c-_Byj6hbY63S7cgcHNc1Ym722YRil8D4uNgwJFZm68-hMe6FFkCZXCIpdiKrC7PzBEte8KDmFBYWTtsg/s1600/04-AngularJs-Model-02.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6HKynDwxIrdcgp9KIbPQkAi3T3jfb2YH9Bg2jdEY6zlfcD0Dic_6Nm7_vX2c-_Byj6hbY63S7cgcHNc1Ym722YRil8D4uNgwJFZm68-hMe6FFkCZXCIpdiKrC7PzBEte8KDmFBYWTtsg/s1600/04-AngularJs-Model-02.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6HKynDwxIrdcgp9KIbPQkAi3T3jfb2YH9Bg2jdEY6zlfcD0Dic_6Nm7_vX2c-_Byj6hbY63S7cgcHNc1Ym722YRil8D4uNgwJFZm68-hMe6FFkCZXCIpdiKrC7PzBEte8KDmFBYWTtsg/s1600/04-AngularJs-Model-02.jpg&quot; height=&quot;222&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div align=&quot;justify&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
You can run the sample application using the Plnkr tool at &lt;a href=&quot;http://plnkr.co/edit/ovVP2zNgcYmLfTWRbrNh?p=preview&quot; rollapp-href=&quot;http://plnkr.co/edit/ovVP2zNgcYmLfTWRbrNh?p=preview&quot; target=&quot;_blank&quot; title=&quot;AngularJs Model&quot;&gt;AngularJs Model&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;ng-show and ng-hide&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
ng-show
 and ng-hide are also directives. These are very helpful when you want 
to hide or show something based on a property or object that either 
contains a value or does not.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
As you seen in the 
aforesaid model example, the string is always displaying like &quot;you 
entered employee name is:&quot;. You can change it so it will only display 
whenever the user has entered a value into a text box field.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
For
 example, when you search for employee details, you need to display some
 message when the user begins searching by entering some employee name.  
 
&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;  
&lt;html&gt;  
  
&lt;head&gt;  
  &lt;!-- 1. Angular JS Script CDN reference added  --&gt;  
  &lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js&quot;&gt;  
  &lt;/script&gt;  
&lt;/head&gt;  
&lt;!-- 2. ng-app directive included --&gt;  
&lt;body ng-app=&quot;&quot;&gt;  
  &lt;h1&gt;
Employee Search&lt;/h1&gt;
&lt;form&gt;
  
    &lt;label&gt;Employee Name:&lt;/label&gt;  
    &lt;!--3. ng-model directive added to the input field with the value empname  --&gt;  
    &lt;input ng-model=&quot;empname&quot; placeholder=&quot;Employee name to find&quot; type=&quot;text&quot; /&gt;  
    
  
    &lt;!--4. ng-show and ng-hide directives will display only empname is not empty --&gt;  
    &lt;pre ng-show=&quot;empname&quot;&gt;Employee Search Started..!!!&lt;/pre&gt;
&lt;pre ng-hide=&quot;!empname&quot;&gt;You enetered employee name is: {{empname}}&lt;/pre&gt;
&lt;/form&gt;
&lt;/body&gt;  
  
&lt;/html&gt; 
&lt;/pre&gt;
&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
The previously described HTML file contains the following two pre tags:&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
The
 first one contains the ng-show directive with the value empname. So, 
The pre tag will be displayed whenever you have entered some text into 
the input filed that has applied the ng-mode is empname.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
The
 second one contains the ng-hide directive with the value !empname (here
 ! Indicates not). So, The pre tag will be hidden when the empname is 
empty. &lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;b&gt;Note:&lt;/b&gt; in both of the preceding 
cases you can use any one of the directives (ng-show or ng-hide) for 
simplicity. But for the purpose of understanding, I have used both 
directives. 
&lt;br /&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
Now, you can run the HTML file and by default it displays like the following.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&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/AVvXsEgd7iP-vMNKGeKDr0_SJ1QlasVjsfMSyrnCocEPrad5A_HUnXVHlga8LEjvM6LOfWFrzB2tpMbYdEl6hr8HKbPi_kgcBA1e6qeXIFlXO2PhAMHVE6Vd5cZJop5vur6s7ghU2IgQAHCJTLQ/s1600/05-AngularJs-Show-Hide-01.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgd7iP-vMNKGeKDr0_SJ1QlasVjsfMSyrnCocEPrad5A_HUnXVHlga8LEjvM6LOfWFrzB2tpMbYdEl6hr8HKbPi_kgcBA1e6qeXIFlXO2PhAMHVE6Vd5cZJop5vur6s7ghU2IgQAHCJTLQ/s1600/05-AngularJs-Show-Hide-01.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgd7iP-vMNKGeKDr0_SJ1QlasVjsfMSyrnCocEPrad5A_HUnXVHlga8LEjvM6LOfWFrzB2tpMbYdEl6hr8HKbPi_kgcBA1e6qeXIFlXO2PhAMHVE6Vd5cZJop5vur6s7ghU2IgQAHCJTLQ/s1600/05-AngularJs-Show-Hide-01.jpg&quot; height=&quot;192&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now, you can enter any of the text in that text box field and then the screen will have the results shown as follows.&lt;/div&gt;
&lt;div&gt;
&lt;/div&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/AVvXsEinoCtPr_QdDjkVSJNwJY76oJlvNJgwHb1YD1QheQIkcx5kI28orYCOm7Na3-ONEPMWxLqIlbyRr1rLuth6iQCC_1I0_6QB3w65Na20Pmn9R96K-V1r3ccEXMvyyZH06rbPx2RQWtT77HE/s1600/06-AngularJs-Show-Hide-02.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinoCtPr_QdDjkVSJNwJY76oJlvNJgwHb1YD1QheQIkcx5kI28orYCOm7Na3-ONEPMWxLqIlbyRr1rLuth6iQCC_1I0_6QB3w65Na20Pmn9R96K-V1r3ccEXMvyyZH06rbPx2RQWtT77HE/s1600/06-AngularJs-Show-Hide-02.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEinoCtPr_QdDjkVSJNwJY76oJlvNJgwHb1YD1QheQIkcx5kI28orYCOm7Na3-ONEPMWxLqIlbyRr1rLuth6iQCC_1I0_6QB3w65Na20Pmn9R96K-V1r3ccEXMvyyZH06rbPx2RQWtT77HE/s1600/06-AngularJs-Show-Hide-02.jpg&quot; height=&quot;240&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&amp;nbsp;You can run the sample application using the Plnkr tool at&amp;nbsp;&lt;a href=&quot;http://plnkr.co/edit/AvvO5SaVn33OpINHMMhy?p=preview&quot; rollapp-href=&quot;http://plnkr.co/edit/AvvO5SaVn33OpINHMMhy?p=preview&quot; target=&quot;_blank&quot; title=&quot;AngularJS Show Hide&quot;&gt;AngularJS Show Hide.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
You can download the aforesaid all examples from this link &lt;a href=&quot;http://goo.gl/8gKjp9&quot; rollapp-href=&quot;http://goo.gl/8gKjp9&quot; target=&quot;_blank&quot;&gt;AngularJS Examples.&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Conclusion&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
I
 hope this article provides you an idea of the history and architecture 
of AngularJS, Binding Expressions and some of the directives like 
ng-app, ng-controller, ng-model, ng-show and ng-hide.&lt;/div&gt;
&lt;div class=&quot;clear&quot;&gt;
&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal; margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div id=&quot;raIcons&quot; style=&quot;display: none;&quot;&gt;
&lt;img class=&quot;raImg&quot; height=&quot;32&quot; src=&quot;https://dfsuknfbz46oq.cloudfront.net/p/icons/kolourpaint.png&quot; width=&quot;32&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/6505975645297690415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2015/01/quick-start-of-angularjs.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/6505975645297690415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/6505975645297690415'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2015/01/quick-start-of-angularjs.html' title='Quick Start Of AngularJS'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/AVvXsEggUTnghRAfP1BnyNxJU_7cKx3bvQs6_JG_LawvlOJmiB1MR8BslghemPHBp4E-52eW9PmyQGG1XzZPb3_-EO09ksh8ZdvX-DU8NiVQl4n848KJMoFHFVo9NP8leQ9nb8fKhyphenhyphenGxemJnvww/s72-c/01-AngularJs-Starter.jpg" height="72" width="72"/><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-8698871401678878675</id><published>2014-11-30T18:40:00.003+05:30</published><updated>2014-11-30T20:30:46.711+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="MVC"/><category scheme="http://www.blogger.com/atom/ns#" term="MVC 5.0"/><category scheme="http://www.blogger.com/atom/ns#" term="Skype"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio 2013"/><title type='text'>Skype Status Display For a User in MVC</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;Scenario&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
This article explains how to display the user Skype status in the user profile in a MVC application. The administrator in a site wants to 
view the list of users with his/her Skype status and also wants to 
chat/call by clicking on the Skype status in the user profile.&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;b style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;Prerequisites&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
To
 display the Skype status in a public site, the Skype user must check 
(select) the privacy setting &quot;Allow my online status to be shown on the 
Web&quot;. You can go to the settings by navigating from the Skype menu 
Privacy settings and check the &quot;Allow my online status to be shown on 
the Web&quot; as shown in the following screenshot.&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/AVvXsEj-P9AOuev2T7WAouC1iG7oooOgEa1InL8Y2VYK9qbnoMuZIBSxajAWYaeWpcPH1lHVN0kEfdvIYdqS8hHSdhh8UM-UhSjf3FXc4s48QGwAliRdfClrRmTjeGd8c2lLS8Lt82rMftFszzw/s1600/01-Skype-Settings.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-P9AOuev2T7WAouC1iG7oooOgEa1InL8Y2VYK9qbnoMuZIBSxajAWYaeWpcPH1lHVN0kEfdvIYdqS8hHSdhh8UM-UhSjf3FXc4s48QGwAliRdfClrRmTjeGd8c2lLS8Lt82rMftFszzw/s1600/01-Skype-Settings.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-P9AOuev2T7WAouC1iG7oooOgEa1InL8Y2VYK9qbnoMuZIBSxajAWYaeWpcPH1lHVN0kEfdvIYdqS8hHSdhh8UM-UhSjf3FXc4s48QGwAliRdfClrRmTjeGd8c2lLS8Lt82rMftFszzw/s1600/01-Skype-Settings.jpg&quot; height=&quot;492&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;b style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;Implementation&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Create a new project named &lt;b&gt;UsersSkypeStatusInMVC&lt;/b&gt; and choose the template &lt;b&gt;MVC&lt;/b&gt;. It then creates an MVC template project.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 2&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Add a Controller named &lt;b&gt;AdminController&lt;/b&gt; with the following procedure. &lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Right-click on the &quot;Controllers&quot; folder and select the &lt;b&gt;Add&lt;/b&gt; option and click on the &quot;Controller&quot; link.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;It opens a pop-up and then select the option &lt;b&gt;MVC 5 Controller – Empty&lt;/b&gt; and then click on the &quot;Add&quot; button.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;Again, it opens a popup and then provide the name as &lt;b&gt;AdminController&lt;/b&gt; and click on the &quot;Add&quot; button. &lt;/li&gt;
&lt;/ol&gt;
Now, the controller is created with a default code.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
In this step, Add a Model named &quot;&lt;b&gt;UserModel&lt;/b&gt;&quot; using the following procedure. &lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Right-click on the &quot;Models&quot; folder and select the &quot;Add&quot; option and click on the &quot;Class...&quot;.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;It opens a pop-up and then enter the name as &quot;UserModel.cs&quot; and click on the Add button. &lt;/li&gt;
&lt;/ol&gt;
After adding the model, replace the existing code in the file &quot;UserModel.cs&quot; with the following code.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharp&quot; name=&quot;code&quot;&gt;namespace UsersSkypeStatusInMVC.Models    
{    
    /// &lt;summary&gt;    
    /// User Model    
    /// &lt;/summary&gt;    
    public class UserModel    
    {    
        public int UserId { get; set; }    
        public string Name { get; set; }    
        public string Email { get; set; }    
        public string SkypeId { get; set; }    
        public string ProfileImagePath { get; set; }    
    
    }    
}  
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 4&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
This step, replace the existing code in the &quot;AdminController.cs&quot; file with the following code.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharp&quot; name=&quot;code&quot;&gt;using System.Collections.Generic;    
using System.Web.Mvc;    
using UsersSkypeStatusInMVC.Models;    
    
namespace UsersSkypeStatusInMVC.Controllers    
{    
    public class AdminController : Controller    
    {    
        // GET: UsersProfile    
        public ActionResult UserProfiles()    
        {    
            List&lt;usermodel&gt; usersList = GetUsers();    
            return View(usersList);    
        }    
    
        /// &lt;summary&gt;    
        /// Get the list of sample users    
        /// &lt;/summary&gt;    
        /// &lt;returns&gt;User List&lt;/returns&gt;    
        private List&lt;usermodel&gt; GetUsers()    
        {    
            var usersList = new List&lt;usermodel&gt;    
            {    
                new UserModel    
                {    
                    UserId = 1,    
                    Name=&quot;Ramchand&quot;,    
                    Email = &quot;ram@abc.com&quot;,    
                    SkypeId = &quot;ramchand.repalle&quot;, // Skype Id    
                    ProfileImagePath = &quot;Ramchand.jpg&quot;    
                },    
                new UserModel    
                {    
                    UserId = 2,    
                    Name=&quot;Abc&quot;,    
                    Email = &quot;chand@abc.com&quot;,    
                    SkypeId = &quot;abctest&quot;,// Skype Id    
                    ProfileImagePath = &quot;abc.jpg&quot;    
                },    
                new UserModel    
                {    
                    UserId = 3,    
                    Name=&quot;def&quot;,    
                    Email = &quot;def@abc.com&quot;,    
                    SkypeId = &quot;ram&quot;,// Skype Id    
                    ProfileImagePath = &quot;def.jpg&quot;    
                }    
            };    
    
            return usersList;    
        }    
    }    
}  
&lt;/usermodel&gt;&lt;/usermodel&gt;&lt;/usermodel&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;About Code&lt;/b&gt; &lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;The GetUsers() method will provide a sample list of users.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;You will call that method in the &lt;b&gt;UserProfiles&lt;/b&gt; Action Result method and then send that list of users to the view. &lt;/li&gt;
&lt;/ol&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 5&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
This step, add a view for the UserProfiles Action controller method by the following procedure:&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Right-click on the &lt;b&gt;View()&lt;/b&gt; method in the &lt;b&gt;UsersProfile&lt;/b&gt; Action method and click on &quot;&lt;b&gt;Add View&lt;/b&gt;&quot;.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;Enter the view name as &quot;&lt;b&gt;UserProfiles&lt;/b&gt;&quot; and then click on the &quot;&lt;b&gt;Add&lt;/b&gt;&quot; button. &lt;/li&gt;
&lt;/ol&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 6&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
This step replaces the existing code in the &quot;&lt;b&gt;UserProfiles.csthtml&lt;/b&gt;&quot; file design with the following code.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;html&quot; name=&quot;code&quot;&gt;@model IEnumerable&lt;usersskypestatusinmvc .models.usermodel=&quot;&quot;&gt;     
    
@{    
    ViewBag.Title = &quot;User Profiles&quot;;    
}    
&lt;h2&gt;
User Profiles&lt;/h2&gt;
&lt;style type=&quot;text/css&quot;&gt;    
    .lblHeader {    
        font-weight: bold;    
    }    
    .userProfile {    
        box-shadow: 10px 10px 5px #888888;     
        width: 300px;     
        height: 200px;    
        float:left;    
        margin-right:30px;    
    }    
&lt;/style&gt;    
    
@foreach (var item in Model)    
{    
    var skypeId = @Html.DisplayFor(modelItem =&amp;gt; item.SkypeId);    
    var profileImg = &quot;../../Images/&quot; + @Html.DisplayFor(modelItem =&amp;gt;     
                        item.ProfileImagePath);    
    &lt;div class=&quot;userProfile&quot;&gt;
&lt;div style=&quot;float: left; min-width: 180px;&quot;&gt;
&lt;label class=&quot;lblHeader&quot;&gt;UserId:&lt;/label&gt;    
            @Html.DisplayFor(modelItem =&amp;gt; item.UserId) &lt;br /&gt;
&lt;label class=&quot;lblHeader&quot;&gt;Name:&lt;/label&gt;    
            @Html.DisplayFor(modelItem =&amp;gt; item.Name) &lt;br /&gt;
&lt;label class=&quot;lblHeader&quot;&gt;Email:&lt;/label&gt;    
            @Html.DisplayFor(modelItem =&amp;gt; item.Email) &lt;br /&gt;
&lt;label class=&quot;lblHeader&quot;&gt;Skype:&lt;/label&gt;    
            &lt;a href=&quot;skype:@skypeId?chat&quot; rollapp-href=&quot;&quot; style=&quot;text-decoration: none;&quot;&gt;    
                &lt;img class=&quot;skypeStatusImg&quot; src=&quot;http://mystatus.skype.com/mediumicon/@skypeId&quot; style=&quot;margin-top: 1px;&quot; /&gt;    
            &lt;/a&gt;    
            &lt;a href=&quot;skype:@skypeId?call&quot; rollapp-href=&quot;&quot; style=&quot;text-decoration: none;&quot;&gt;    
                &lt;img src=&quot;http://www.skypeassets.com/i/scom/images/skype-    
                           buttons/callbutton_24px.png&quot; /&gt;    
            &lt;/a&gt;    
        &lt;/div&gt;
&lt;div&gt;
&lt;img alt=&quot;ProfilePic&quot; height=&quot;100&quot; src=&quot;@profileImg&quot; width=&quot;100&quot; /&gt;    
        &lt;/div&gt;
&lt;/div&gt;
}    
&lt;div class=&quot;clearfix&quot;&gt;
&lt;/div&gt;
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&gt;    
    function SkypeUserStatus() {    
        $(&quot;.skypeStatusImg&quot;).each(function () {    
            var imgSrc = $(this).attr(&quot;src&quot;).split(&quot;?&quot;)[0] + &quot;?&quot;;    
            $(this).attr(&quot;src&quot;, imgSrc + new Date().getTime());    
        });    
    }    
    setInterval(SkypeUserStatus, 1000);    
&lt;/script&gt;
&lt;/usersskypestatusinmvc&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;About the Design&lt;/b&gt;&amp;nbsp;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;Added a namespace to get the list of users.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;CSS styles are defined.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;A foreach loop helps to display the list of users with respective details.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;Skype:
 {SKYPE ID}?chat: This is the href tag, you can use to chat the Skype by
 clicking on that. For example: skype:ramchand.repalle?chat&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;Skype:
 {SKYPE ID}?call: This is the href tag, you can use to call the Skype by
 clicking on that. For example: skype:ramchand.repalle?call&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;JavaScript function SkypeUserStatus helps to assign the Skype status image.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;SetInterVal has been used to call the SkypeUserStatus function periodically to get the current Skype status of a user. &lt;/li&gt;
&lt;/ol&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 7&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
This
 step helps you about Skype Status URL information and other details. To
 display the Skype status of any user, you have to request the URL 
format as follows.&lt;br /&gt;
&lt;br /&gt;
The format of the URL is:&lt;b&gt; http://mystatus.skype.com/&lt;/b&gt;{SIZE OF ICON}/{SKYPE ID}&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;{SIZE OF ICON}:&lt;/b&gt; It indicates to display the size of the icon based on user Skype status.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;For example:&lt;/b&gt; smallicon, mediumicon&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;{SKYPE ID}:&lt;/b&gt; It indicates the Skype Id of the user.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;For example:&lt;/b&gt; ramchand.repalle&lt;br /&gt;
&lt;br /&gt;
So, the example of the Skype status URL is &lt;b&gt;http://mystatus.skype.com/mediumicon/ramchand.repalle.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
You can get the status of the user by just clicking on the previously shown URL.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 8&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Add a new folder named “&lt;b&gt;Images&lt;/b&gt;” with sample images to the “&lt;b&gt;UsersSkypeStatusInMVC&lt;/b&gt;” project. It helps display the sample image for the profile picture as mentioned in the &quot;&lt;b&gt;GetUsers()&lt;/b&gt;&quot; method in AdminController.&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/AVvXsEjyeMZC1Kz38EQAfh4XO1YqBfMezoQ2XXr51kb0mM612r3_gNgo-4DlkaVxxWaQ9DcpSRMmppFLep0KotFNitcLi6is9_0MDnQAuzMKxdLvgXkt8JIIEK2YtoVPbIg0vvKUGbbdj7M1OME/s1600/10-image-folder-with-sample-images.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyeMZC1Kz38EQAfh4XO1YqBfMezoQ2XXr51kb0mM612r3_gNgo-4DlkaVxxWaQ9DcpSRMmppFLep0KotFNitcLi6is9_0MDnQAuzMKxdLvgXkt8JIIEK2YtoVPbIg0vvKUGbbdj7M1OME/s1600/10-image-folder-with-sample-images.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjyeMZC1Kz38EQAfh4XO1YqBfMezoQ2XXr51kb0mM612r3_gNgo-4DlkaVxxWaQ9DcpSRMmppFLep0KotFNitcLi6is9_0MDnQAuzMKxdLvgXkt8JIIEK2YtoVPbIg0vvKUGbbdj7M1OME/s1600/10-image-folder-with-sample-images.jpg&quot; height=&quot;400&quot; width=&quot;346&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 9&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Now, build the application (F6), then run (hit F5) an application and navigate to the following URL: &lt;b&gt;(http://localhost:57882/Admin/UserProfiles).&lt;/b&gt;&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/AVvXsEhf7ByQ7AQRjz07tlx9_Nk3K-GAGv-oUdtqHUhUNK3eTC7KW62QrvnFbXGrQJgtttpEBjMJa7DW5K-Q41SF57ws0fbaV0XDmV8NfpRASeDcyU0baJknNv3dRXT4cCoD9BXolhtFtlhNldc/s1600/11-user-profiles-01.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf7ByQ7AQRjz07tlx9_Nk3K-GAGv-oUdtqHUhUNK3eTC7KW62QrvnFbXGrQJgtttpEBjMJa7DW5K-Q41SF57ws0fbaV0XDmV8NfpRASeDcyU0baJknNv3dRXT4cCoD9BXolhtFtlhNldc/s1600/11-user-profiles-01.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhf7ByQ7AQRjz07tlx9_Nk3K-GAGv-oUdtqHUhUNK3eTC7KW62QrvnFbXGrQJgtttpEBjMJa7DW5K-Q41SF57ws0fbaV0XDmV8NfpRASeDcyU0baJknNv3dRXT4cCoD9BXolhtFtlhNldc/s1600/11-user-profiles-01.jpg&quot; height=&quot;268&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt; &lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&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/AVvXsEjhwrkWAsjAcukZ23YWjM56w6vdNuQrRinVR6cH6L7PGCLHT6uYYNfVjefdOOYGtlfn-PvE8Px0wAFbhMIOt9Nxb0dHHZ-xjsZbjBN45LSdi29Q_k3SM93SFGXp3nQpDHhFiIqW2w0mJ0Q/s1600/12-user-profiles-02.png&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhwrkWAsjAcukZ23YWjM56w6vdNuQrRinVR6cH6L7PGCLHT6uYYNfVjefdOOYGtlfn-PvE8Px0wAFbhMIOt9Nxb0dHHZ-xjsZbjBN45LSdi29Q_k3SM93SFGXp3nQpDHhFiIqW2w0mJ0Q/s1600/12-user-profiles-02.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjhwrkWAsjAcukZ23YWjM56w6vdNuQrRinVR6cH6L7PGCLHT6uYYNfVjefdOOYGtlfn-PvE8Px0wAFbhMIOt9Nxb0dHHZ-xjsZbjBN45LSdi29Q_k3SM93SFGXp3nQpDHhFiIqW2w0mJ0Q/s1600/12-user-profiles-02.png&quot; height=&quot;222&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
As in the preceding screenshots by clicking on the (Skype) icon it 
displays a popup to launch the application in Skype. You just click on 
that then it would open a Skype user window.&lt;br /&gt;
&lt;br /&gt;
The Skype status images are displayed as described below.&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/AVvXsEjfJh681rIQah4-zoem26GRtPNC_eMqRODBElaLFgZOzGs8W_tSJkxyBz3kgT_gOmph7gG1knCzwhYdPuCmHYgwpDLBUF_0kbWwJ6CX09pKg1Aat4irmugotoW_Knb37iQrQTGQuxjZYiU/s1600/13-skype-status-image.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfJh681rIQah4-zoem26GRtPNC_eMqRODBElaLFgZOzGs8W_tSJkxyBz3kgT_gOmph7gG1knCzwhYdPuCmHYgwpDLBUF_0kbWwJ6CX09pKg1Aat4irmugotoW_Knb37iQrQTGQuxjZYiU/s1600/13-skype-status-image.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfJh681rIQah4-zoem26GRtPNC_eMqRODBElaLFgZOzGs8W_tSJkxyBz3kgT_gOmph7gG1knCzwhYdPuCmHYgwpDLBUF_0kbWwJ6CX09pKg1Aat4irmugotoW_Knb37iQrQTGQuxjZYiU/s1600/13-skype-status-image.jpg&quot; height=&quot;266&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The discussed project source code can be downloaded from the link &lt;a href=&quot;http://goo.gl/DLGcBy&quot; rel=&quot;nofollow&quot; rollapp-href=&quot;http://goo.gl/DLGcBy&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;Source Code&lt;/span&gt;&lt;/a&gt;.&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;Conclusion&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;
&lt;br /&gt;
I hope this article helps you to display the Skype user status with the user profile details in a MVC application.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div id=&quot;raIcons&quot; style=&quot;display: none;&quot;&gt;
&lt;img class=&quot;raImg&quot; height=&quot;32&quot; src=&quot;https://dfsuknfbz46oq.cloudfront.net/p/icons/kolourpaint.png&quot; width=&quot;32&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/8698871401678878675/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2014/11/skype-status-display-for-user-in-mvc.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/8698871401678878675'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/8698871401678878675'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2014/11/skype-status-display-for-user-in-mvc.html' title='Skype Status Display For a User in MVC'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/AVvXsEj-P9AOuev2T7WAouC1iG7oooOgEa1InL8Y2VYK9qbnoMuZIBSxajAWYaeWpcPH1lHVN0kEfdvIYdqS8hHSdhh8UM-UhSjf3FXc4s48QGwAliRdfClrRmTjeGd8c2lLS8Lt82rMftFszzw/s72-c/01-Skype-Settings.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-2722646018285110901</id><published>2014-11-30T16:45:00.000+05:30</published><updated>2014-11-30T16:45:35.803+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="Multi-language"/><category scheme="http://www.blogger.com/atom/ns#" term="MVC 5.0"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio 2013"/><title type='text'>Multilingual MVC Application With Customized JS Bundles Based on User Language</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div align=&quot;justify&quot;&gt;
&lt;b style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;About&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
This article shows how to create multilingual MVC applications with JS bundles based on various languages. Here,
 you will learn about multilingual MVC application implementation flow, 
the creation of customized JavaScript bundles with translated alert 
messages based on user language, custom HTML helper classes, how to set 
user language in a cookie based on his login, displaying resource 
translation values in a form and how to maintain names and values in 
resource files.&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;Scenario&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
You
 will implement an MVC application to be displayed in various languages 
based on the user selected language. The form content is being displayed
 from the resource file based on the name and respective language and it
 would need to display the alert kind of information from &lt;b&gt;customized bundled JavaScript based on user language&lt;/b&gt; whenever the user has done a form submission or input validation and so on.&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;RoadMap&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt; &lt;br /&gt;
When implementing the previous sample MVC application, you will learn the following concepts.&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt; Resource File creation with key, value pair combination for required language.&lt;br /&gt;
 &lt;/li&gt;
&lt;li&gt; Resource Key value display in a form based on user language.&lt;br /&gt;
 &lt;/li&gt;
&lt;li&gt; Cookie implementation in MVC.&lt;br /&gt;
 &lt;/li&gt;
&lt;li&gt; Bundling and Minification.&lt;br /&gt;
 &lt;/li&gt;
&lt;li&gt; Custom HTML helper class.&lt;br /&gt;
 &lt;/li&gt;
&lt;li&gt; Customized Bundle creation.&lt;br /&gt;
 &lt;/li&gt;
&lt;li&gt; Translate the JavaScript&amp;nbsp;alert messages into user selected language.&lt;br /&gt;
 &lt;/li&gt;
&lt;li&gt; Localized JavaScripts&amp;nbsp;minified and bundled, It helps to increase the performance of form.&lt;/li&gt;
&lt;/ol&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Create a new project named &lt;b&gt;“MultilingualMVCApp”&lt;/b&gt; and choose the template &lt;b&gt;“MVC”&lt;/b&gt; then it creates an MVC template project.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 2&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;Add a new application folder named &lt;b&gt;“App_GlobalResources”&lt;/b&gt; to maintain the resource files with key/value pair combinations for various languages.&lt;/span&gt;
 Right-click on the Project “MultiLingualMVCApp” and select on “Add” and
 then select “Add ASP.NET Folder” and then click on 
“App_GlobalResources” like the following.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&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/AVvXsEhnoGhC2xqhpezBbnPoC8iEOLevhfq8Ak1DMDj_xVeIk1Gpvk1Pe6uDXVC8qz9aiBkBE6sS4KfI2qimAowC_4KG9WT4UWvLWw_AiaxU2_pG0sGBAsYjGQ7Oj6gVYuiWqoJZXXybYBAC8pg/s1600/04-app-globalresoourcefolder-adding.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnoGhC2xqhpezBbnPoC8iEOLevhfq8Ak1DMDj_xVeIk1Gpvk1Pe6uDXVC8qz9aiBkBE6sS4KfI2qimAowC_4KG9WT4UWvLWw_AiaxU2_pG0sGBAsYjGQ7Oj6gVYuiWqoJZXXybYBAC8pg/s1600/04-app-globalresoourcefolder-adding.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnoGhC2xqhpezBbnPoC8iEOLevhfq8Ak1DMDj_xVeIk1Gpvk1Pe6uDXVC8qz9aiBkBE6sS4KfI2qimAowC_4KG9WT4UWvLWw_AiaxU2_pG0sGBAsYjGQ7Oj6gVYuiWqoJZXXybYBAC8pg/s1600/04-app-globalresoourcefolder-adding.jpg&quot; height=&quot;310&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=4172426161974972492&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://www.blogger.com/blogger.g?blogID=4172426161974972492&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;/a&gt;&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 3&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
Create
 a resource file named “Notifications.resx” for the default language 
English by following the following screenshots. Right-click on the 
“App_GlobalResources” folder, select “Add” and then click on “Resource 
file” and specify the name as “Notifications” and then click on the “Ok”
 button.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&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/AVvXsEhCrwZRbOgyfFwPwKGqUmO3oUw7aExc7_Tp36jai1wJ5dSv8yztzuWx0MUPQlNsfTqDHIjTVNB7doI5GbzC4ZXcOrdTUZEHJhVfT2n0yoeM1emrl_KjTVgG8re6nwY1SUrPJkrX44QTLMU/s1600/05-reource-file-creation-template.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCrwZRbOgyfFwPwKGqUmO3oUw7aExc7_Tp36jai1wJ5dSv8yztzuWx0MUPQlNsfTqDHIjTVNB7doI5GbzC4ZXcOrdTUZEHJhVfT2n0yoeM1emrl_KjTVgG8re6nwY1SUrPJkrX44QTLMU/s1600/05-reource-file-creation-template.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCrwZRbOgyfFwPwKGqUmO3oUw7aExc7_Tp36jai1wJ5dSv8yztzuWx0MUPQlNsfTqDHIjTVNB7doI5GbzC4ZXcOrdTUZEHJhVfT2n0yoeM1emrl_KjTVgG8re6nwY1SUrPJkrX44QTLMU/s1600/05-reource-file-creation-template.jpg&quot; height=&quot;230&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
Click on &quot;Resources File&quot; and provide the name as &quot;Notifications&quot; as shown in the following screenshot.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&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/AVvXsEhCButSBG6M3o6LmjXJqZuSe5OUd4B2k7GVPEOlF_cX69lRlxR2ALkduB2pzq44pud_6-dYTG7Skd82MnoqhpyUD22hPbnoFifxh-83LOHeHXKO8nSyBnfssL_6nkSXNUrJQZPFeXSA3IE/s1600/06-resource-file-template-name.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCButSBG6M3o6LmjXJqZuSe5OUd4B2k7GVPEOlF_cX69lRlxR2ALkduB2pzq44pud_6-dYTG7Skd82MnoqhpyUD22hPbnoFifxh-83LOHeHXKO8nSyBnfssL_6nkSXNUrJQZPFeXSA3IE/s1600/06-resource-file-template-name.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCButSBG6M3o6LmjXJqZuSe5OUd4B2k7GVPEOlF_cX69lRlxR2ALkduB2pzq44pud_6-dYTG7Skd82MnoqhpyUD22hPbnoFifxh-83LOHeHXKO8nSyBnfssL_6nkSXNUrJQZPFeXSA3IE/s1600/06-resource-file-template-name.jpg&quot; height=&quot;194&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
In the similar way, create another resource file named 
“Notifications.fr.resx” under the App_GlobalResources file. After 
completion of these aforesaid procedure, the Solution Explorer looks 
like the following. &lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&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/AVvXsEjeviHeUIWQKZQR67NDr6YZ-Jk5FgQkYna7rWKjLDVkF99IfODeOpPcK4HKgYP10jS6WW7gxpahc2DCs7_lCuUp9lJTxVfpiHSl6j7yF0Xep2ryOfRX1BVQHTl_T0INb7BquEzjz9fJNCY/s1600/07-solution-explorer-with-resource-files.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeviHeUIWQKZQR67NDr6YZ-Jk5FgQkYna7rWKjLDVkF99IfODeOpPcK4HKgYP10jS6WW7gxpahc2DCs7_lCuUp9lJTxVfpiHSl6j7yF0Xep2ryOfRX1BVQHTl_T0INb7BquEzjz9fJNCY/s1600/07-solution-explorer-with-resource-files.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeviHeUIWQKZQR67NDr6YZ-Jk5FgQkYna7rWKjLDVkF99IfODeOpPcK4HKgYP10jS6WW7gxpahc2DCs7_lCuUp9lJTxVfpiHSl6j7yF0Xep2ryOfRX1BVQHTl_T0INb7BquEzjz9fJNCY/s1600/07-solution-explorer-with-resource-files.jpg&quot; height=&quot;600&quot; width=&quot;492&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 4&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
In
 this step, you will add sample resource keys with translation values 
for English and French languages. For that double click on the 
“Notifications.resx” file, then the displayed file has three columns 
named Name, Value and Comments.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
&lt;b&gt;Name:&lt;/b&gt; This name field is treated as the Resource Key value and &lt;b&gt;it should be unique in the file and not be empty.&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
You can now enter the sample key and respective values as shown in the following screenshot for the default language (English).&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&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/AVvXsEhgeIQxhau0W1zn1z4MdRTEuZ8OeymQNSxgoOaU5E9VMg9g0aIpOckf8vfw30qMZTQr2jMtrXug0JgIi6m8vgJxBxksqYrhD-9-Xl7WSomQPUgpEUi0qY0_GfA9eP7CtI-Tpt1aIOzNLrs/s1600/08-english-resource-keys.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgeIQxhau0W1zn1z4MdRTEuZ8OeymQNSxgoOaU5E9VMg9g0aIpOckf8vfw30qMZTQr2jMtrXug0JgIi6m8vgJxBxksqYrhD-9-Xl7WSomQPUgpEUi0qY0_GfA9eP7CtI-Tpt1aIOzNLrs/s1600/08-english-resource-keys.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgeIQxhau0W1zn1z4MdRTEuZ8OeymQNSxgoOaU5E9VMg9g0aIpOckf8vfw30qMZTQr2jMtrXug0JgIi6m8vgJxBxksqYrhD-9-Xl7WSomQPUgpEUi0qY0_GfA9eP7CtI-Tpt1aIOzNLrs/s1600/08-english-resource-keys.jpg&quot; height=&quot;176&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
In the same way, you can add the same key values, whichever were 
specified in the “Notifications.resx” with respective translated values 
for the French language in the “Notifications.fr.resx” file is as 
follows.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&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/AVvXsEhGp1djRPtJBQkYsMDwtQgyLch5iQ05k0j8cOZo9W4yiJuo1zAIndx6h79dm3G5heCpZCeJMQ11SE2b4NW2tKUFjCYADWvmD9QfC7NwNR_uHyC280gQD1RpdMinafY5DOtfymD9VU403hc/s1600/09-french-resource-values.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGp1djRPtJBQkYsMDwtQgyLch5iQ05k0j8cOZo9W4yiJuo1zAIndx6h79dm3G5heCpZCeJMQ11SE2b4NW2tKUFjCYADWvmD9QfC7NwNR_uHyC280gQD1RpdMinafY5DOtfymD9VU403hc/s1600/09-french-resource-values.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhGp1djRPtJBQkYsMDwtQgyLch5iQ05k0j8cOZo9W4yiJuo1zAIndx6h79dm3G5heCpZCeJMQ11SE2b4NW2tKUFjCYADWvmD9QfC7NwNR_uHyC280gQD1RpdMinafY5DOtfymD9VU403hc/s1600/09-french-resource-values.jpg&quot; height=&quot;168&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;b&gt;Note:&lt;/b&gt; Here, I have used the Google translator to translate the sample English content to French content.&lt;/div&gt;
In
 the same way, you can add various resource files for different 
languages as said and you can add multiple resource types to the resx 
files (like strings, images, icons and so on) based on your needs.&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/AVvXsEge6flu5GFiwACWjgQFoNqL-B-BzCWKP2y-0xgXvfKPSgc_Q_F4DYJWiSiIZhHZiy__uEEoz6hPsj_tyU1gZejsTs4Fqjzr8g7Fnl1-NUB9QdG5aM-8uYWrLeeMxWsFl8xvWVAlCj3i_zc/s1600/10-resource-file-options.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEge6flu5GFiwACWjgQFoNqL-B-BzCWKP2y-0xgXvfKPSgc_Q_F4DYJWiSiIZhHZiy__uEEoz6hPsj_tyU1gZejsTs4Fqjzr8g7Fnl1-NUB9QdG5aM-8uYWrLeeMxWsFl8xvWVAlCj3i_zc/s1600/10-resource-file-options.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEge6flu5GFiwACWjgQFoNqL-B-BzCWKP2y-0xgXvfKPSgc_Q_F4DYJWiSiIZhHZiy__uEEoz6hPsj_tyU1gZejsTs4Fqjzr8g7Fnl1-NUB9QdG5aM-8uYWrLeeMxWsFl8xvWVAlCj3i_zc/s1600/10-resource-file-options.jpg&quot; height=&quot;268&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 5&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
You
 can now create one controller named “DemoController” with the following
 procedure.&amp;nbsp; Right-click on the “Controllers” folder and select the 
“Add” option and click on the “Controller” link.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&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/AVvXsEiK_WP9n4Cf5EN9wbzys1bcT2mm3UN_UPmKFj68lwzO8XsmzByi1vDGJp3nSqNiGq-b-7Ou4uk_ZY1K3uoaAdk25B9Y7v5YGR01sucB0b4WO3Y0XHpD8IrABdMHaYznctGteOxspIAs0ro/s1600/11-demo-controller-creation.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK_WP9n4Cf5EN9wbzys1bcT2mm3UN_UPmKFj68lwzO8XsmzByi1vDGJp3nSqNiGq-b-7Ou4uk_ZY1K3uoaAdk25B9Y7v5YGR01sucB0b4WO3Y0XHpD8IrABdMHaYznctGteOxspIAs0ro/s1600/11-demo-controller-creation.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiK_WP9n4Cf5EN9wbzys1bcT2mm3UN_UPmKFj68lwzO8XsmzByi1vDGJp3nSqNiGq-b-7Ou4uk_ZY1K3uoaAdk25B9Y7v5YGR01sucB0b4WO3Y0XHpD8IrABdMHaYznctGteOxspIAs0ro/s1600/11-demo-controller-creation.jpg&quot; height=&quot;182&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
Click on the &quot;Controller..&quot; link and select the option &lt;b&gt;“MVC 5 Controller – Empty”&lt;/b&gt; and then click on the “Add” button. Then, specify the name as&lt;b&gt; “DemoController”&lt;/b&gt; then click on the “Add” button.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
Now, the controller is created with the default action named “Index” like the following.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&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/AVvXsEhG7CKJwmYLlGk1xVjzB5pM-aMoMpwHvE5cADC480rjSw0fT9laHESlo4RTc3s6-vD-0Yy4ddE412wr7x6rr-lk71W1dleFmuE41DH7iR6shXJjSbJa342HwiUnumcxVJwxWMdxEsUK7SI/s1600/14-demo-controller-code.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG7CKJwmYLlGk1xVjzB5pM-aMoMpwHvE5cADC480rjSw0fT9laHESlo4RTc3s6-vD-0Yy4ddE412wr7x6rr-lk71W1dleFmuE41DH7iR6shXJjSbJa342HwiUnumcxVJwxWMdxEsUK7SI/s1600/14-demo-controller-code.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhG7CKJwmYLlGk1xVjzB5pM-aMoMpwHvE5cADC480rjSw0fT9laHESlo4RTc3s6-vD-0Yy4ddE412wr7x6rr-lk71W1dleFmuE41DH7iR6shXJjSbJa342HwiUnumcxVJwxWMdxEsUK7SI/s1600/14-demo-controller-code.jpg&quot; height=&quot;336&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 6&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
Add
 a view to the Index action method by right-clicking on the View 
function and click on “Add View” and then click on the Ok button. The 
following screenshots help you do that.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&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/AVvXsEjt9xpRSaPY5Vihoor6xKNbB2xU-AXVtGZ-BAnkCysKzwIGl98w0odKaCApFzi7Cwo0IqeiTUWSU3dgbaLRLetfbhCILJHRLS30t2JMY1bBOJic50OYp6ufWlaCvyn9pbLzW6lDafwEDV8/s1600/15-add-view-to-index-action-method.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt9xpRSaPY5Vihoor6xKNbB2xU-AXVtGZ-BAnkCysKzwIGl98w0odKaCApFzi7Cwo0IqeiTUWSU3dgbaLRLetfbhCILJHRLS30t2JMY1bBOJic50OYp6ufWlaCvyn9pbLzW6lDafwEDV8/s1600/15-add-view-to-index-action-method.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt9xpRSaPY5Vihoor6xKNbB2xU-AXVtGZ-BAnkCysKzwIGl98w0odKaCApFzi7Cwo0IqeiTUWSU3dgbaLRLetfbhCILJHRLS30t2JMY1bBOJic50OYp6ufWlaCvyn9pbLzW6lDafwEDV8/s1600/15-add-view-to-index-action-method.jpg&quot; height=&quot;164&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
Click on &quot;Add View...&quot; then it opens a popup like the following.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&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/AVvXsEjJngoJNWUL5mQhTQ5kao3KCkChyQl_IhAhGBJJctJLMMj5ocgkPvdKjTgSUMEyHnHhRSncBR5HfTA78qcUCJ9MOPY7CBKrntXOHDa5xq78TgWuP1up9iHlez5an_hqqWNq414nmvrB54c/s1600/16-add-view-template-to-index-action-method.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJngoJNWUL5mQhTQ5kao3KCkChyQl_IhAhGBJJctJLMMj5ocgkPvdKjTgSUMEyHnHhRSncBR5HfTA78qcUCJ9MOPY7CBKrntXOHDa5xq78TgWuP1up9iHlez5an_hqqWNq414nmvrB54c/s1600/16-add-view-template-to-index-action-method.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJngoJNWUL5mQhTQ5kao3KCkChyQl_IhAhGBJJctJLMMj5ocgkPvdKjTgSUMEyHnHhRSncBR5HfTA78qcUCJ9MOPY7CBKrntXOHDa5xq78TgWuP1up9iHlez5an_hqqWNq414nmvrB54c/s1600/16-add-view-template-to-index-action-method.jpg&quot; height=&quot;392&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
Now, click on the &quot;Add&quot; button and then it will create an Index.cshtml file.&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 7&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt; &lt;br /&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
Replace
 the existing design with the following design format that contains a 
sample form to enter the user name, select the user preferred language 
and the submit button.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;html&quot; name=&quot;code&quot;&gt;@{  
    ViewBag.Title = &quot;Index&quot;;  
}  
  
&lt;h2&gt;
Demo&lt;/h2&gt;
&lt;div&gt;
@using (Html.BeginForm(&quot;Index&quot;, &quot;Demo&quot;, FormMethod.Post))  
    {  
        &lt;label&gt;Enter User Name&lt;/label&gt;  
        &lt;input class=&quot;form-control&quot; name=&quot;txtName&quot; placeholder=&quot;Guest&quot; type=&quot;text&quot; /&gt;  
        &lt;br /&gt;
&lt;label&gt;Select Language:&lt;/label&gt;  
        &lt;select class=&quot;form-control&quot; name=&quot;ddlLanguage&quot;&gt;  
            &lt;option value=&quot;en&quot;&gt;English&lt;/option&gt;  
            &lt;option value=&quot;fr&quot;&gt;French&lt;/option&gt;  
        &lt;/select&gt;  
        &lt;br /&gt;
&lt;input class=&quot;form-control&quot; name=&quot;Submit&quot; type=&quot;submit&quot; /&gt;  
    }  
&lt;/div&gt;
&lt;/pre&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
Now, build the application (F6) and run the application (F5) with the following URL (&lt;a href=&quot;http://localhost:49624/Demo/Index&quot; rollapp-href=&quot;http://localhost:49624/Demo/Index&quot;&gt;http://localhost:49624/Demo/Index&lt;/a&gt;) then the displayed form looks like the following.&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&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/AVvXsEgP-eCSq8yPtpOVydzm49OvPjet9uXe4U4c_X8_wWa-Zcm2ioXJvpGvfGNrFMpO37Za94ejiy4Y2WPMEPXxgfsHdcVC_3Pitesovn5U6N9gTdC2AAllIQHHnLYCgqrr8X7m1R2oI_yWfaU/s1600/17-demo-form-display.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgP-eCSq8yPtpOVydzm49OvPjet9uXe4U4c_X8_wWa-Zcm2ioXJvpGvfGNrFMpO37Za94ejiy4Y2WPMEPXxgfsHdcVC_3Pitesovn5U6N9gTdC2AAllIQHHnLYCgqrr8X7m1R2oI_yWfaU/s1600/17-demo-form-display.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgP-eCSq8yPtpOVydzm49OvPjet9uXe4U4c_X8_wWa-Zcm2ioXJvpGvfGNrFMpO37Za94ejiy4Y2WPMEPXxgfsHdcVC_3Pitesovn5U6N9gTdC2AAllIQHHnLYCgqrr8X7m1R2oI_yWfaU/s1600/17-demo-form-display.jpg&quot; height=&quot;494&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 8&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In 
this step, write a piece of code for the post action of the submit 
button to set the user language code in the cookie, the user name in the
 &lt;b&gt;TempData&lt;/b&gt; object (that helps to send data from one controller request to another) and then redirects to the home page.&lt;/div&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharp&quot; name=&quot;code&quot;&gt;    [HttpPost]  
     public ActionResult Index(FormCollection collection)  
     {  
         TempData.Add(&quot;LoggedInUser&quot;, collection[&quot;txtName&quot;]);  
         string language = collection[&quot;ddlLanguage&quot;];  
         SetCulture(language);  
      
         return RedirectToAction(&quot;Home&quot;);  
     }  
      
     /// &lt;summary&gt;  
     /// Set the culture based on culture code and set the   
     /// value in cookie  
     /// &lt;/summary&gt;  
     /// &lt;param name=&quot;cultureCode&quot; /&gt;  
     private void SetCulture(string cultureCode)  
     {  
      
         var cookieCultureLanguage = new HttpCookie(&quot;UserLanguage&quot;)  
         {  
             Value = cultureCode  
         };  
      
         Response.Cookies.Set(cookieCultureLanguage);  
      
         //Sets  Culture for Current thread  
         Thread.CurrentThread.CurrentCulture =  
         System.Globalization.CultureInfo.CreateSpecificCulture(&quot;en&quot;);  
      
         //Ui Culture for Localized text in the UI  
         Thread.CurrentThread.CurrentUICulture =  
         new System.Globalization.CultureInfo(cultureCode);  
      
     }  
&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
The cookie that you have set in the previous code using the method &lt;b&gt;“SetCulture”&lt;/b&gt; helps to display the respective user-selected language translated values in a form from the resource file.&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 9&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
In this step, add one controller action method named &lt;b&gt;“Home”&lt;/b&gt; to the &lt;b&gt;&quot;DemoController.cs&quot;&lt;/b&gt; file with the respective view named &lt;b&gt;“Home.cshtml”&lt;/b&gt; file.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;csharp&quot; name=&quot;code&quot;&gt;/// &lt;summary&gt;  
/// Home Action Controller Method  
/// &lt;/summary&gt;  
/// &lt;returns&gt;&lt;/returns&gt;  
public ActionResult Home()  
{  
    return View();  
}
&lt;/pre&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
Then, right-click on the View() method 
in the Home action and then click on &quot;Add View..&quot;. After clicking on 
“Add View” it opens a template then click on the “Add” button then it 
creates a “Home.cshtml” page with default design. You can leave the 
design as it is, in later steps you can add the respective design 
changes.&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 10&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;Add a method named &lt;b&gt;“&lt;/b&gt;&lt;/span&gt;&lt;b&gt;Application_AcquireRequestState&lt;/b&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;”&lt;/b&gt; to the &lt;b&gt;Global.asax.cs&lt;/b&gt;
 file that helps to set the culture based on the user-selected language 
if the cookie exists else it sets the default culture to English.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharp&quot; name=&quot;code&quot;&gt;/// &lt;summary&gt;  
 /// Application AcquireRequestState  
 /// &lt;/summary&gt;  
 /// &lt;param name=&quot;sender&quot; /&gt;  
 /// &lt;param name=&quot;e&quot; /&gt;  
 protected void Application_AcquireRequestState(object sender,   
EventArgs e)  
 {  
  
     string culture;  
     HttpCookie cookie = Request.Cookies[&quot;UserLanguage&quot;];  
     if (cookie != null &amp;amp;&amp;amp; cookie.Value != null   
        &amp;amp;&amp;amp; cookie.Value.Trim() != string.Empty)  
         culture = cookie.Value;  
     else  
         culture = &quot;en&quot;;  
  
     //Default Language/Culture for all number, Date format  
     System.Threading.Thread.CurrentThread.CurrentCulture =  
     System.Globalization.CultureInfo.CreateSpecificCulture(&quot;en&quot;);  
  
     //Ui Culture for Localized text in the UI  
     System.Threading.Thread.CurrentThread.CurrentUICulture =  
     new System.Globalization.CultureInfo(culture);  
 }
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 11&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt; &lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
In
 this step, you will implement a customized JavaScript bundle translator
 class. It helps to bundle the JavaScript with the respective 
user-selected language translated messages if any exists in the 
JavaScript file like alert, input validation messages and so on.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
So,
 first create a new folder named “ResourceHandler”. For that right-click
 on the project “MultiLingualMVCApp” then select “Add” and click on “Add
 New Folder” and provide the name as “ResourceHandler” and then add a 
class file “JSTranslator” under the newly created folder 
&quot;ResourceHandler&quot;. &lt;/div&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
Replace the “JSTranslator.cs” file code with the following code.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;csharp&quot; name=&quot;code&quot;&gt;    using System.Text.RegularExpressions;  
    using System.Web;  
    using System.Web.Optimization;  
      
    namespace MultiLingualMVCApp.ResourceHandler  
    {  
        public class JSTranslator : IBundleTransform  
        {  
            #region IBundleTransform  
      
            /// &lt;summary&gt;  
            /// IBundleTransform Process method  
            /// &lt;/summary&gt;  
            /// &lt;param name=&quot;context&quot; /&gt;Bundle Context  
            /// &lt;param name=&quot;response&quot; /&gt;Bundle Response  
            public void Process(BundleContext context, BundleResponse response)  
            {  
                string translated = ScriptTranslator(response.Content);  
                response.Content = translated;  
            }  
     
            #endregion  
     
            #region Localization Of Js Bundle Flow  
      
            private static readonly Regex Regex =   
                new Regex(@&quot;GetResourceValue\(([^\))]*)\)&quot;,  
                               RegexOptions.Singleline | RegexOptions.Compiled);  
      
            /// &lt;summary&gt;  
            /// Translated script based on JavaScript content  
            /// &lt;/summary&gt;  
            /// &lt;param name=&quot;text&quot; /&gt;  
            /// &lt;returns&gt;&lt;/returns&gt;  
            private string ScriptTranslator(string text)  
            {  
                MatchCollection matches = Regex.Matches(text);  
                foreach (Match match in matches)  
                {  
                    object obj = HttpContext.GetGlobalResourceObject(&quot;Notifications&quot;,   
                        match.Groups[1].Value);  
                    if (obj != null)  
                        text = text.Replace(match.Value, CleanText(obj.ToString()));  
                }  
      
                return text;  
            }  
      
            /// &lt;summary&gt;  
            /// Format the text as Clean while displaying  
            /// in JavaScript notifications  
            /// &lt;/summary&gt;  
            /// &lt;param name=&quot;text&quot; /&gt;  
            /// &lt;returns&gt;&lt;/returns&gt;  
            private static string CleanText(string text)  
            {  
                text = text.Replace(&quot;&#39;&quot;, &quot;&quot;);  
                return text;  
            }  
     
            #endregion  
        }  
    }  
&lt;/pre&gt;
&lt;br /&gt;
&amp;nbsp;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;About JSTranslator.cs code&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt; &lt;div style=&quot;font-weight: normal;&quot;&gt;
The JsTranslator class is inherited from the “IbundleTransform”.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div style=&quot;font-weight: normal;&quot;&gt;
The
 Process method is implemented, as it just gets the BundleResponse 
content and translates the JavaScript with user-selected language 
alerts, if any, using the ScriptTranslator method and will be assigned 
back to that content to the BundleResonse.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div style=&quot;font-weight: normal;&quot;&gt;
The Regex expression is the key term we used in script files, based on that formatted the regex expression.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div style=&quot;font-weight: normal;&quot;&gt;
The Regex Key Term example, you used in scripts is: GetResourceValue(ResourceKeyName)&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div style=&quot;font-weight: normal;&quot;&gt;
The
 ScriptTranslator method first gets the MatchCollection object based on 
regex expression and then based on the Match collection key name get the
 translated value using the method “GetGlobalResourceObject”&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div style=&quot;font-weight: normal;&quot;&gt;
The GetGlobalResourceObject takes the parameters of Resource file name and Resource Key name.&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt; &lt;div style=&quot;font-weight: normal;&quot;&gt;
The CleanText method helps to clean if any characters that creates a problem when displaying in JavaScript.&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
So, you have now successfully added a custom JavaScript bundle class.&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 12&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
In this step, you will add two JavaScript&amp;nbsp;files with sample functions under the “Scripts” folder.&lt;/div&gt;
&lt;div&gt;
The first JavaScript file named “UserNotifications” file. It contains the following function.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;html&quot; name=&quot;code&quot;&gt;function UserTermsNotification() {  
    alert(&#39;GetResourceValue(UserTermsDisplayNotification)&#39;);  
}  
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
The second JavaScript&amp;nbsp;file is named “UserOperations”. It contains the following functions.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;html&quot; name=&quot;code&quot;&gt;function AddUserMessage() {  
    alert(&#39;GetResourceValue(UserAdded)&#39;);  
}  
  
function DeleteUserMessage() {  
    alert(&#39;GetResourceValue(UserDeleted)&#39;);  
} 
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 13&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt; &lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
In this step, you will bundle the previously created JavaScript files in &lt;b&gt;BundleConfig.cs&lt;/b&gt; (that exists in the &lt;b&gt;App_Start&lt;/b&gt;
 folder) using a custom JavaScript&amp;nbsp;bundle that you have created in the 
JSTranslator.cs file. So, add the following code block to the &lt;b&gt;RegisterBundles&lt;/b&gt; method and also add the required namespaces; those are:&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
using System.Collections.Generic;&lt;br /&gt;
using MultiLingualMVCApp.ResourceHandler;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;csharp&quot; name=&quot;code&quot;&gt;    using System.Web;  
      
    namespace MultiLingualMVCApp  
    {  
        public class HtmlHelpers  
        {  
            /// &lt;summary&gt;  
            /// Localized JavaScript bundle   
            /// &lt;/summary&gt;  
            /// &lt;param name=&quot;fileName&quot; /&gt;  
            /// &lt;returns&gt;&lt;/returns&gt;  
            public static HtmlString LocalizedJsBundle(string fileName)  
            {  
                string culture;  
                var cookie = HttpContext.Current.Request.Cookies[&quot;UserLanguage&quot;];  
                if (cookie != null &amp;amp;&amp;amp; cookie.Value != null   
                    &amp;amp;&amp;amp; cookie.Value.Trim() != string.Empty)  
                    culture = cookie.Value;  
                else  
                    culture = &quot;en&quot;;  
                fileName = string.Concat(fileName, &quot;-&quot;, culture);  
                var output = (HtmlString)System.Web.Optimization.Scripts  
                    .Render(fileName);  
                return output;  
            }  
        }  
    }  
&lt;/pre&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b style=&quot;font-size: 14pt;&quot;&gt;Step 14&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
In
 this step, you will implement the custom HTML helper class that helps 
to create a custom JavaScript bundle based on your needs. So, add a new 
class file named &lt;b&gt;HtmlHelpers&lt;/b&gt; under the &lt;b&gt;App_Start&lt;/b&gt; folder and then replace that with the following code.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;csharp&quot; name=&quot;code&quot;&gt;using System.Web;  
  
namespace MultiLingualMVCApp  
{  
    public class HtmlHelpers  
    {  
        /// &lt;summary&gt;  
        /// Localized JavaScript bundle   
        /// &lt;/summary&gt;  
        /// &lt;param name=&quot;fileName&quot; /&gt;  
        /// &lt;returns&gt;&lt;/returns&gt;  
        public static HtmlString LocalizedJsBundle(string fileName)  
        {  
            string culture;  
            var cookie = HttpContext.Current.Request.Cookies[&quot;UserLanguage&quot;];  
            if (cookie != null &amp;amp;&amp;amp; cookie.Value != null   
                &amp;amp;&amp;amp; cookie.Value.Trim() != string.Empty)  
                culture = cookie.Value;  
            else  
                culture = &quot;en&quot;;  
            fileName = string.Concat(fileName, &quot;-&quot;, culture);  
            var output = (HtmlString)System.Web.Optimization.Scripts  
                .Render(fileName);  
            return output;  
        }  
    }  
}
&lt;/pre&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
&amp;nbsp;In the aforesaid &lt;b&gt;Steps 13 and 14&lt;/b&gt;, you have included the custom JavaScript bundle in the &lt;b&gt;BundleConfig.cs&lt;/b&gt; file and created a&amp;nbsp;&lt;b&gt;custom HTML helper&lt;/b&gt; class to use that specified language bundle based on the user-selected language.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The
 Bundling and Minification concept is very helpful to reduce the network
 traffic and file size while loading the form since it minifies the 
multiple JavaScript files into one file and the file is being cached. If
 you change the file content then it automatically gets the fresh 
content with a new version number. So it helps to increase the page 
performance in all aspects.&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 15&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
In this step, you update the “Home.cshtml” form design with the following design.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&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/AVvXsEioRI_8ZuNe_iNEQrtKiCHYA8yzpSxuqQcW2lXqxE_E5GQNg-rsu2SbhX6MKVw4GlLWVNV5boUVJ6mbhcDT6322mg6NuIV1kXGTmejyRzORZ_xNgpjK08sldn8gLQrFNp_QMxAl4gfoSPs/s1600/31-home-cshtml-file-formatted.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioRI_8ZuNe_iNEQrtKiCHYA8yzpSxuqQcW2lXqxE_E5GQNg-rsu2SbhX6MKVw4GlLWVNV5boUVJ6mbhcDT6322mg6NuIV1kXGTmejyRzORZ_xNgpjK08sldn8gLQrFNp_QMxAl4gfoSPs/s1600/31-home-cshtml-file-formatted.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEioRI_8ZuNe_iNEQrtKiCHYA8yzpSxuqQcW2lXqxE_E5GQNg-rsu2SbhX6MKVw4GlLWVNV5boUVJ6mbhcDT6322mg6NuIV1kXGTmejyRzORZ_xNgpjK08sldn8gLQrFNp_QMxAl4gfoSPs/s1600/31-home-cshtml-file-formatted.jpg&quot; height=&quot;296&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
You are done with the multi-language MVC application implementation 
process with user language-specific JavaScript&amp;nbsp;bundled minified files.&lt;span style=&quot;font-weight: normal;&quot;&gt; So, build the application (F6) and hit the (F5) key to run the application with the following URL (&lt;/span&gt;&lt;a href=&quot;http://localhost:49624/Demo/Index&quot; rollapp-href=&quot;http://localhost:49624/Demo/Index&quot;&gt;http://localhost:49624/Demo/Index&lt;/a&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;). &lt;/span&gt; &lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
Enter the user name and select the preferred language as English then the form will be displayed like the following.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&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/AVvXsEh7cH2O8wxAWicJ4XwTUif_GI3bfm_MLG7APG_0NoIqgDY4srW-f4u9f18oG4gLKf8RfUm9p2zw1jApznbQYCec5gg7SzfRLO1XIWFsCHv_DBi0gTiH7a6bqYli8nenTpmF-kWFagMRsPA/s1600/25-user-submit-form.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7cH2O8wxAWicJ4XwTUif_GI3bfm_MLG7APG_0NoIqgDY4srW-f4u9f18oG4gLKf8RfUm9p2zw1jApznbQYCec5gg7SzfRLO1XIWFsCHv_DBi0gTiH7a6bqYli8nenTpmF-kWFagMRsPA/s1600/25-user-submit-form.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7cH2O8wxAWicJ4XwTUif_GI3bfm_MLG7APG_0NoIqgDY4srW-f4u9f18oG4gLKf8RfUm9p2zw1jApznbQYCec5gg7SzfRLO1XIWFsCHv_DBi0gTiH7a6bqYli8nenTpmF-kWFagMRsPA/s1600/25-user-submit-form.jpg&quot; height=&quot;614&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
Now, click on the Submit button then it navigates to the home page like the following.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&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/AVvXsEgPLnXP1h3O5jfI5hXcw9ALGUWCKT5p6_tcBIljUBpSgjU5zAKvl-4NW-w-jz9fwYTqJUr6unA3HhEF6yJWe8aeaAAb0gTdGLSw0GKFyDEo-4yGaldx1jzoJsD4Lv72iWTNxCr4-iDnty8/s1600/26-user-home-form-formatted.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPLnXP1h3O5jfI5hXcw9ALGUWCKT5p6_tcBIljUBpSgjU5zAKvl-4NW-w-jz9fwYTqJUr6unA3HhEF6yJWe8aeaAAb0gTdGLSw0GKFyDEo-4yGaldx1jzoJsD4Lv72iWTNxCr4-iDnty8/s1600/26-user-home-form-formatted.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPLnXP1h3O5jfI5hXcw9ALGUWCKT5p6_tcBIljUBpSgjU5zAKvl-4NW-w-jz9fwYTqJUr6unA3HhEF6yJWe8aeaAAb0gTdGLSw0GKFyDEo-4yGaldx1jzoJsD4Lv72iWTNxCr4-iDnty8/s1600/26-user-home-form-formatted.jpg&quot; height=&quot;406&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The preceding page is self-explanatory about the implemented 
functionality. In the similar way when you click on the &quot;Add User&quot; and 
&quot;Delete User&quot; buttons then it displays the alerts in the English 
language.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Step 16&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;In this step, again you navigate to this URL (&lt;/span&gt;&lt;a href=&quot;http://localhost:49624/Demo/Index&quot; rollapp-href=&quot;http://localhost:49624/Demo/Index&quot;&gt;http://localhost:49624/Demo/Index&lt;/a&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;) and select the user language as French and check the respective outputs as shown below.&lt;/span&gt;&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/AVvXsEhOAqxM3whok2rWTYZtFP9QDCS0UsN-z6F1dO8S0xItUsMmo4Gf-KmAW4KMQ1eSzkipKuZZ4J-TyM35o0tuW7oURY660dzRVMIN0QJzj_1-msQnCY4BZ6bRn9uUAdryxzExBJej_hOSLPg/s1600/28-user-submit-form-french.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOAqxM3whok2rWTYZtFP9QDCS0UsN-z6F1dO8S0xItUsMmo4Gf-KmAW4KMQ1eSzkipKuZZ4J-TyM35o0tuW7oURY660dzRVMIN0QJzj_1-msQnCY4BZ6bRn9uUAdryxzExBJej_hOSLPg/s1600/28-user-submit-form-french.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOAqxM3whok2rWTYZtFP9QDCS0UsN-z6F1dO8S0xItUsMmo4Gf-KmAW4KMQ1eSzkipKuZZ4J-TyM35o0tuW7oURY660dzRVMIN0QJzj_1-msQnCY4BZ6bRn9uUAdryxzExBJej_hOSLPg/s1600/28-user-submit-form-french.jpg&quot; height=&quot;558&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;Now, click on the &quot;Submit&quot; button, then it navigates to the home page.&lt;/span&gt;&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/AVvXsEh3T6KoZOpMc3aEEm1DiDmJBBqCTDRpduz4Wxotn5LFQ7JL4uhyphenhyphenxOiSkOYSrweM5PQ4MunT-vG9DWESHKqNlyUlmvUt0sIkYVV9hxFGSp5qZEwwtNWTwg51yWD3berir3fjjJld__nIC_I/s1600/29-user-home-form-french-formatted.jpg&quot; imageanchor=&quot;1&quot; rollapp-href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3T6KoZOpMc3aEEm1DiDmJBBqCTDRpduz4Wxotn5LFQ7JL4uhyphenhyphenxOiSkOYSrweM5PQ4MunT-vG9DWESHKqNlyUlmvUt0sIkYVV9hxFGSp5qZEwwtNWTwg51yWD3berir3fjjJld__nIC_I/s1600/29-user-home-form-french-formatted.jpg&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3T6KoZOpMc3aEEm1DiDmJBBqCTDRpduz4Wxotn5LFQ7JL4uhyphenhyphenxOiSkOYSrweM5PQ4MunT-vG9DWESHKqNlyUlmvUt0sIkYVV9hxFGSp5qZEwwtNWTwg51yWD3berir3fjjJld__nIC_I/s1600/29-user-home-form-french-formatted.jpg&quot; height=&quot;400&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
The preceding page is self-explanatory 
about the implemented functionality. In the similar way when you click 
on the &quot;Add User&quot; and &quot;Delete User&quot; buttons then it displays the alerts 
in the French language.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
You can download the preceding discussed sample project at &lt;a href=&quot;https://www.dropbox.com/s/5ghaw9s3plkviwo/MultiLingualMVCApp.zip?dl=0&quot; rollapp-href=&quot;http://goo.gl/3rPBwP&quot; target=&quot;_blank&quot;&gt;Source Code&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;Conclusion&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
I
 hope this article provides an idea of the implementation of 
multilingual MVC application flow, creation of customized JavaScript 
bundles with translated alert messages based on user language, custom 
HTML helper classes, how to set user language in a cookie based on his 
login, Displaying Resource translation values in a form and how to 
maintain names and values in resource files.&lt;span style=&quot;font-weight: normal;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div id=&quot;raIcons&quot; style=&quot;display: none;&quot;&gt;
&lt;img class=&quot;raImg&quot; height=&quot;32&quot; src=&quot;https://dfsuknfbz46oq.cloudfront.net/p/icons/kolourpaint.png&quot; width=&quot;32&quot; /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/2722646018285110901/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2014/11/multilanguage-sample-mvc-application.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/2722646018285110901'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/2722646018285110901'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2014/11/multilanguage-sample-mvc-application.html' title='Multilingual MVC Application With Customized JS Bundles Based on User Language'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/AVvXsEhnoGhC2xqhpezBbnPoC8iEOLevhfq8Ak1DMDj_xVeIk1Gpvk1Pe6uDXVC8qz9aiBkBE6sS4KfI2qimAowC_4KG9WT4UWvLWw_AiaxU2_pG0sGBAsYjGQ7Oj6gVYuiWqoJZXXybYBAC8pg/s72-c/04-app-globalresoourcefolder-adding.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-4453555917674407819</id><published>2014-11-30T15:12:00.000+05:30</published><updated>2014-11-30T15:12:27.867+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C# 6.0"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio 2015"/><title type='text'>Literals and Seperators in C# 6.0</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span id=&quot;ctl00_ContentMain_LabelCodeDetail&quot;&gt;&lt;/span&gt;&lt;br /&gt;
This 
feature is very helpful to write more readable code while initializing 
properties and variables for numerical values with new syntax for &lt;b&gt;byte&lt;/b&gt; and &lt;b&gt;long&lt;/b&gt; types.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Binary:&lt;/b&gt;
&lt;br /&gt;
The new syntax for declaring binary property now, you can use &lt;b&gt;0b&lt;/b&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt; as a prefix.&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;csharp&quot; name=&quot;code&quot;&gt;public byte BinaryCode {get; } =  0b1010; 
&lt;/pre&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;b&gt;Long:&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
The new syntax for declaring long type property to provide ability to use&lt;b&gt; underscore (_)&lt;/b&gt; as a separator. Its much easier to look at the value like billions or millions etc.&lt;br /&gt;
&lt;pre class=&quot;csharp&quot; name=&quot;code&quot;&gt;public long Number {get; } = 1_000_000_000;
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/4453555917674407819/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2014/11/literals-and-seperators-in-csharp-6.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/4453555917674407819'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/4453555917674407819'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2014/11/literals-and-seperators-in-csharp-6.html' title='Literals and Seperators in C# 6.0'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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-4172426161974972492.post-128176000026202137</id><published>2014-11-30T15:03:00.000+05:30</published><updated>2014-11-30T15:03:05.096+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C# 6.0"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio 2015"/><title type='text'>Exception Filters in C# 6.0</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
This feature helps to filter the exception messages by providing conditional statements which returns &lt;b&gt;true or false at catch block&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
Suppose, if you want to log the exception in catch block &lt;b&gt;only if inner exception is not null&lt;/b&gt;. In that scenario, you can write the code like the below.&lt;br /&gt;
&lt;div&gt;
&amp;nbsp;So, In the catch block&lt;b&gt;&amp;nbsp;if condition returns true&lt;/b&gt; then it enters into the catch block and it would log and throws the exception.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;pre class=&quot;csharp&quot; name=&quot;code&quot;&gt;try  
{  
   //Some Exception Throws  
}  
catch(Exception ex) if(ex.InnerException != null)  
{  
   //Log the Exception and throw  
   throw;  
}  
finally  
{  
}  
&lt;/pre&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/128176000026202137/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2014/11/exception-filters-in-csharp-6.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/128176000026202137'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/128176000026202137'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2014/11/exception-filters-in-csharp-6.html' title='Exception Filters in C# 6.0'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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-4172426161974972492.post-3229260234161061413</id><published>2014-11-30T14:57:00.000+05:30</published><updated>2014-11-30T14:57:56.838+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C# 6.0"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio 2015"/><title type='text'>Conditional Access in C# 6.0</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This feature is very helpful to use in a scenario like to get the &lt;b&gt;property value from the object only if object is not null.&lt;/b&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
For
 Example, you are considering delegate Action as the parameter to any of
 the method, You want to get the name from the Action Method only if 
Action is not null and Action.Method is not null.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
You can easily get an idea by just looking the below code. &lt;/div&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSharp&quot; name=&quot;code&quot;&gt;public void LogAction(Action action)  
{  
    //Before C# 6.0  
    var actionName = &quot;Empty&quot;;  
    if (action != null &amp;amp;&amp;amp; action.Method != null)  
    {  
        actionName = action.Method.Name;  
    }  
  
    //C# 6.0  
    var actionName = action?.Method?.Name ?? &quot;Empty&quot;;  
  
}  
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
As per the above code in C# 6.0, action is not null and Method is not null then only &quot;Name&quot; property value is assigned otherwise &quot;Empty&quot; value will be assigned.
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/3229260234161061413/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2014/11/conditional-access-in-csharp-6.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/3229260234161061413'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/3229260234161061413'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2014/11/conditional-access-in-csharp-6.html' title='Conditional Access in C# 6.0'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-4008199007938656884</id><published>2014-10-28T20:25:00.000+05:30</published><updated>2014-10-28T20:28:44.275+05:30</updated><title type='text'>ContentResult in MVC</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 24pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;About&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div align=&quot;JUSTIFY&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
ContentResult is one of
the ActionResult type in MVC. This is mostly used to display dynamic
content to the user based on various conditions. So, you can return
various types of content like plain text, xml, html etc. 
&lt;/div&gt;
&lt;div align=&quot;JUSTIFY&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;JUSTIFY&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
In this article you are
going to learn about the following things.&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;&lt;div align=&quot;JUSTIFY&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
ContentResult and
 its properties&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;&lt;ul&gt;
&lt;li&gt;&lt;div align=&quot;JUSTIFY&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
Content&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div align=&quot;JUSTIFY&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
ContentType&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div align=&quot;JUSTIFY&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
ContentEncoding&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;ol start=&quot;2&quot;&gt;
&lt;li&gt;Return various Types of Content&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;&lt;ul&gt;
&lt;li&gt;&lt;div align=&quot;JUSTIFY&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
Plain Text&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div align=&quot;JUSTIFY&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
Html&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;div align=&quot;JUSTIFY&quot; style=&quot;margin-bottom: 0in;&quot;&gt;
XML&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 24pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;ContentResult and its Properties&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;Content:&lt;/b&gt; Its used to send the
content data in a string format.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;b&gt;ContentType:&lt;/b&gt;&lt;b&gt; &lt;/b&gt;It helps to indicate the content type. The default content type
for ContentResult is text/html; charset=utf-8.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: left;&quot;&gt;
&lt;b&gt;ContentEncoding:&lt;/b&gt; It helps to indicate the content encoding type, the default encoding&amp;nbsp; type&amp;nbsp; for ContentResult&amp;nbsp; is UTF-8.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: left;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 24pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Return Various Types of Content&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
In this scenario, you will get a more
idea by creating sample application with the following these steps.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;Step 1:&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
Create a new project with the name
ContentResultDemo and choose the template as Empty as shown in the
following screen shots.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&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/AVvXsEjzxL0WPie9SIkkETxhccEgxO4u6SkoiwBs_IqYh7UuQiGMbgtK8hsYU6f_HrVZKBEoMLLSgJyCJsleT8Us793Mv13xw5Vnt_v7ni4dzf8RiZelfjc4oK-jOAlhaMPi8cR2oJaMoVgOP4g/s1600/01-new-project.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzxL0WPie9SIkkETxhccEgxO4u6SkoiwBs_IqYh7UuQiGMbgtK8hsYU6f_HrVZKBEoMLLSgJyCJsleT8Us793Mv13xw5Vnt_v7ni4dzf8RiZelfjc4oK-jOAlhaMPi8cR2oJaMoVgOP4g/s1600/01-new-project.jpg&quot; height=&quot;388&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
Now, click on Ok button  then the
screen would display like the below.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&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/AVvXsEhmcJhed-qNpqGtYSy1-GUjF_9TBxVcAlFk2Z4I56bMQI18P5371vT2ntzkI79PMgtcSrnHthoBwmDrpIDPgteMH2iSHam9lJPP7n1AqMnl6W-j0G03P3A3-D8pYmTvp1blOmpD7ybFDKA/s1600/02-project-template.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhmcJhed-qNpqGtYSy1-GUjF_9TBxVcAlFk2Z4I56bMQI18P5371vT2ntzkI79PMgtcSrnHthoBwmDrpIDPgteMH2iSHam9lJPP7n1AqMnl6W-j0G03P3A3-D8pYmTvp1blOmpD7ybFDKA/s1600/02-project-template.jpg&quot; height=&quot;476&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;Step 2:&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
After clicking on Ok button the project would be created.&amp;nbsp; Then create a controller named as
“ContentDemoController” like the below.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&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/AVvXsEhxioxcDL8UCCWZBnOcLL67ricZcwlnVanl-eNaJIqFnRO1r4CceX4qs6NBomreLcNi3gfZsW8MZ9KjK7tpdjJkm2ujqZn2Re3nBc3GZtpIuuKXI2aBgBQd75yOcl2tgRDQa_auVqcDnfM/s1600/03-add-controller.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxioxcDL8UCCWZBnOcLL67ricZcwlnVanl-eNaJIqFnRO1r4CceX4qs6NBomreLcNi3gfZsW8MZ9KjK7tpdjJkm2ujqZn2Re3nBc3GZtpIuuKXI2aBgBQd75yOcl2tgRDQa_auVqcDnfM/s1600/03-add-controller.jpg&quot; height=&quot;214&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
Now, click on &quot;Controller&quot; then the displayed screen is as follows.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&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/AVvXsEiOP8pP7qUebgtKqLctpV9f4MyDVHMARvgFplkCS9XXwvusealaOpqB2dKUxzjFerUeHZbokOlEiAOHN3BzSUFWl4diN_b82WlXUgXegHP2KRA-fEbLlXrjM9BIIDhakfTEgLh81k3MP6o/s1600/04-controller-template.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOP8pP7qUebgtKqLctpV9f4MyDVHMARvgFplkCS9XXwvusealaOpqB2dKUxzjFerUeHZbokOlEiAOHN3BzSUFWl4diN_b82WlXUgXegHP2KRA-fEbLlXrjM9BIIDhakfTEgLh81k3MP6o/s1600/04-controller-template.jpg&quot; height=&quot;442&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
Click on &quot;Add&quot;&amp;nbsp; button then the output template window is as follows.&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/AVvXsEiLglOIpSE_Phqsb_YEczr2szj_Y0B7V8hq9M5LWl_wk8NP3XcbcGbCfX4ylnBvznBwy3HKo8FbUZ3cxkFMoHjlJwWMv_OEh4Z22KX5F2gu36Q-f0nnmsFE_jf_KICbBIkbRwuL9WQ-hfk/s1600/05-controller-name-template.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiLglOIpSE_Phqsb_YEczr2szj_Y0B7V8hq9M5LWl_wk8NP3XcbcGbCfX4ylnBvznBwy3HKo8FbUZ3cxkFMoHjlJwWMv_OEh4Z22KX5F2gu36Q-f0nnmsFE_jf_KICbBIkbRwuL9WQ-hfk/s1600/05-controller-name-template.jpg&quot; height=&quot;136&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
Enter the name as &quot;ContentDemoController&quot; as mentioned in the aforesaid screenshot and then click on &quot;Add&quot; button then controller would be created and its displayed like the below.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&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/AVvXsEgh6NLm3PZ7IgJiqLoWdFnYsdNmwXW1HBZ1rm4RkdEv4hD3P-TTuanAr25kp1P1JFagbCk2K60Vc8bAvaeIZTwXgAK7zas_MmN4CtYMDlZf3OFq3Oonu1lm16ngYPFiSk8awFkDZqZ4ums/s1600/06-controller-default-code.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgh6NLm3PZ7IgJiqLoWdFnYsdNmwXW1HBZ1rm4RkdEv4hD3P-TTuanAr25kp1P1JFagbCk2K60Vc8bAvaeIZTwXgAK7zas_MmN4CtYMDlZf3OFq3Oonu1lm16ngYPFiSk8awFkDZqZ4ums/s1600/06-controller-default-code.jpg&quot; height=&quot;478&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;b&gt;Step 3:&lt;/b&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
Now, Replace the default code in the ContentDemoController.cs file with the following code.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;using System.Web.Mvc;

namespace ContentResultDemo.Controllers
{
    public class ContentDemoController : Controller
    {
        // GET: ContentDemo
        public ActionResult Index()
        {
            return Content(&quot;test content&quot;);
        }
    }
}&lt;/pre&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
And then Build the application (hit F6) and run the application (hit F5) then navigate to the following Url (http://localhost:50589/ContentDemo/)&lt;br /&gt;
&lt;br /&gt;
Note: The port address in the above Url might be a chance to changed at your end.&lt;br /&gt;
&lt;br /&gt;
The output screen looks like below.&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/AVvXsEhuWdigQ695yAruPEf_XZB-_h3cjpgR4fBRcFjZngLeEMBf53hidMIGVMzNa1vUOl5SvOYjx9XYgUoF8-fm6W1IuUOKt0yjCBomrIO0JJOHbgH__tZmH5bbRIHqXUL0W9zKEw-41UTCxwQ/s1600/07-sample-output.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhuWdigQ695yAruPEf_XZB-_h3cjpgR4fBRcFjZngLeEMBf53hidMIGVMzNa1vUOl5SvOYjx9XYgUoF8-fm6W1IuUOKt0yjCBomrIO0JJOHbgH__tZmH5bbRIHqXUL0W9zKEw-41UTCxwQ/s1600/07-sample-output.jpg&quot; height=&quot;176&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Till now, you have created one Index action method with sample test content in the ContentDemoController.cs&amp;nbsp; file.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 4:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Add the following code in ContentDemo controller class file which helps to return sample content based on its content type.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;        /// &lt;summary&gt;
        /// Returns sample content based on its content type
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;contentType&quot; /&gt;content type
        /// &lt;returns&gt;As String&lt;/returns&gt;
        public string SampleContent(int contentType)
        {
            switch (contentType)
            {
                case (int)ContentTypes.PlainText:
                    return &quot;Plain Text&quot;;
                case (int)ContentTypes.Html:
                    return &quot;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;Name&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Ramchand&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Test&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&quot;;
                case (int)ContentTypes.Xml:
                    return &quot;&lt;employees&gt;&quot; +
                           &quot;&lt;employee&gt;&lt;name&gt;Ramchand&lt;/name&gt;&lt;/employee&gt;&quot; +
                           &quot;&lt;employee&gt;&lt;name&gt;Srinivas&lt;/name&gt;&lt;/employee&gt;&quot; +
                           &quot;&lt;/employees&gt;&quot;;
                default:
                    return string.Empty;
            }
        }

        /// &lt;summary&gt;
        /// Content Types enum
        /// &lt;/summary&gt;
        public enum ContentTypes
        {
            PlainText = 1,
            Html,
            Xml
        }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Plain Text:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
To display the plain text by using ContentResult as return type, you have to add the below action method.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;        /// &lt;summary&gt;
        /// Returns Plain Content
        /// &lt;/summary&gt;
        /// &lt;returns&gt;&lt;/returns&gt;
        public ActionResult PlainContent()
        {
            return Content(SampleContent((int)ContentTypes.PlainText), 
                        &quot;text/plain&quot;);
        }
&lt;/pre&gt;
&lt;br /&gt;
Now, run the application (hit F5) and navigate to this Url (http://localhost:50589/ContentDemo/PlainContent) then the displayed output is like the below.&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/AVvXsEgyoQ4x4CXnkYOPDLwULHTvTTkiSP-esNt77m710p-PE5cISNwgM-GdhX5KesB32sYfrahHepbFjfCO6E8dLmhXfWkULF_8s3wzGCyt7DufVP8PdgIG3pNt7tvXEkyN48kPIHUWwKXIbwM/s1600/08-plain-text-output.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyoQ4x4CXnkYOPDLwULHTvTTkiSP-esNt77m710p-PE5cISNwgM-GdhX5KesB32sYfrahHepbFjfCO6E8dLmhXfWkULF_8s3wzGCyt7DufVP8PdgIG3pNt7tvXEkyN48kPIHUWwKXIbwM/s1600/08-plain-text-output.jpg&quot; height=&quot;216&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Html:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
To display the Html output, add the following action controller method with this code &lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;        /// &lt;summary&gt;
        /// Returns Html Content
        /// &lt;/summary&gt;
        /// &lt;returns&gt;&lt;/returns&gt;
        public ActionResult HtmlContent()
        {
            return Content(SampleContent((int)ContentTypes.Html), 
                        &quot;text/html&quot;);
        }
&lt;/pre&gt;
&lt;br /&gt;
Now, run the application (hit F5) and navigate to this Url (http://localhost:50589/ContentDemo/HtmlContent) then the displayed output is like the below.&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/AVvXsEipS3T1cUZ-ho0x_R9WbzaFdK-LzhqyvwFKpA3LnBogDyK4PwhEYCTVOIFDZe1PIVwmz8CvrF1W8IClrsPi94zpguHGnvkVLdQ280d_p_LCQ5Z70_TRLZ1jU9M4ryv8lTBas2naGgskWys/s1600/09-html-output.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipS3T1cUZ-ho0x_R9WbzaFdK-LzhqyvwFKpA3LnBogDyK4PwhEYCTVOIFDZe1PIVwmz8CvrF1W8IClrsPi94zpguHGnvkVLdQ280d_p_LCQ5Z70_TRLZ1jU9M4ryv8lTBas2naGgskWys/s1600/09-html-output.jpg&quot; height=&quot;248&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Xml:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
To display the Xml output, add the below action method in the ContenDemoController.cs file&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;        /// &lt;summary&gt;
        /// Returns Xml Content
        /// &lt;/summary&gt;
        /// &lt;returns&gt;&lt;/returns&gt;
        public ActionResult XmlContent()
        {
            return Content(SampleContent((int)ContentTypes.Xml), 
                        &quot;application/xml&quot;);
        }
&lt;/pre&gt;
&lt;br /&gt;
Now, run the application (hit F5) and navigate to this Url (http://localhost:50589/ContentDemo/XmlContent) then the displayed output is like the below.&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/AVvXsEiEKoiOUC5gNsWVfAwgiM_Iyem-W9pvhEpZ9GWYNcu0YhfeptX_qHUcMIe-uFBZ-3LDdKM65Zr8vs6gYuaQwvtBNtysPWfDqr6GNgtKOlfZgT1Qkgcn4gO0oNNuF7OAz1bxQTCdgdlWTjM/s1600/10-xml-output.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiEKoiOUC5gNsWVfAwgiM_Iyem-W9pvhEpZ9GWYNcu0YhfeptX_qHUcMIe-uFBZ-3LDdKM65Zr8vs6gYuaQwvtBNtysPWfDqr6GNgtKOlfZgT1Qkgcn4gO0oNNuF7OAz1bxQTCdgdlWTjM/s1600/10-xml-output.jpg&quot; height=&quot;316&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
As, you have observed in the above examples, the &lt;b&gt;Content property for Content Result is only string&lt;/b&gt;. Even though &lt;b&gt;while displaying at browser it would changes based on the content type&lt;/b&gt; which you have specified in the Content Result.&lt;br /&gt;
&lt;br /&gt;
The whole code you have implemented in the ContentDemoController.cs file is as follows.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;using System.Web.Mvc;

namespace ContentResultDemo.Controllers
{
    public class ContentDemoController : Controller
    {
        // GET: ContentDemo
        public ActionResult Index()
        {
            return Content(&quot;test content&quot;);
        }

        /// &lt;summary&gt;
        /// Returns Plain Content
        /// &lt;/summary&gt;
        /// &lt;returns&gt;&lt;/returns&gt;
        public ActionResult PlainContent()
        {
            return Content(SampleContent((int)ContentTypes.PlainText), 
                        &quot;text/plain&quot;);
        }

        /// &lt;summary&gt;
        /// Returns Html Content
        /// &lt;/summary&gt;
        /// &lt;returns&gt;&lt;/returns&gt;
        public ActionResult HtmlContent()
        {
            return Content(SampleContent((int)ContentTypes.Html),
                        &quot;text/html&quot;);
        }

        /// &lt;summary&gt;
        /// Returns Xml Content
        /// &lt;/summary&gt;
        /// &lt;returns&gt;&lt;/returns&gt;
        public ActionResult XmlContent()
        {
            return Content(SampleContent((int)ContentTypes.Xml), 
                        &quot;application/xml&quot;);
        }

        /// &lt;summary&gt;
        /// Returns sample content based on its content type
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;contentType&quot; /&gt;content type
        /// &lt;returns&gt;As String&lt;/returns&gt;
        public string SampleContent(int contentType)
        {
            switch (contentType)
            {
                case (int)ContentTypes.PlainText:
                    return &quot;Plain Text&quot;;
                case (int)ContentTypes.Html:
                    return &quot;&lt;table&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;Name&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Ramchand&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Test&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&quot;;
                case (int)ContentTypes.Xml:
                    return &quot;&lt;employees&gt;&quot; +
                           &quot;&lt;employee&gt;&lt;name&gt;Ramchand&lt;/name&gt;&lt;/employee&gt;&quot; +
                           &quot;&lt;employee&gt;&lt;name&gt;Srinivas&lt;/name&gt;&lt;/employee&gt;&quot; +
                           &quot;&lt;/employees&gt;&quot;;
                default:
                    return string.Empty;
            }
        }

        /// &lt;summary&gt;
        /// Content Types enum
        /// &lt;/summary&gt;
        public enum ContentTypes
        {
            PlainText = 1,
            Html,
            Xml
        }

    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: left;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 24pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Conclusion&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&amp;nbsp;
&lt;br/&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;I hope you got an idea about ContentResult and its properties and how can you send various types of content by just changing the ContentType property in ContentResult.&lt;/span&gt; Please provide your suggestions and comments if any.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/4008199007938656884/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2014/10/contentresult-in-mvc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/4008199007938656884'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/4008199007938656884'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2014/10/contentresult-in-mvc.html' title='ContentResult in MVC'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/AVvXsEjzxL0WPie9SIkkETxhccEgxO4u6SkoiwBs_IqYh7UuQiGMbgtK8hsYU6f_HrVZKBEoMLLSgJyCJsleT8Us793Mv13xw5Vnt_v7ni4dzf8RiZelfjc4oK-jOAlhaMPi8cR2oJaMoVgOP4g/s72-c/01-new-project.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-2077494225607632656</id><published>2014-10-22T15:47:00.000+05:30</published><updated>2014-10-22T15:54:54.728+05:30</updated><title type='text'>JsonResult Type in MVC</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div align=&quot;justify&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 24pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;About&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt; &lt;/div&gt;
JsonResult is an ActionResult type in MVC. It helps to send the content in&amp;nbsp;JavaScript Obect Notation (JSON) format.&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 24pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;History&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
To
 learn more about ActionResult and some of the other following action 
result types, please go through the following articles in my blog.&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt; &lt;a href=&quot;http://ramchandr.blogspot.com/2014/09/action-result-return-type-in-mvc-50.html&quot; target=&quot;_blank&quot;&gt;Action Result&lt;/a&gt;&lt;br /&gt;
 &lt;/li&gt;
&lt;li&gt; &lt;a href=&quot;http://ramchandr.blogspot.com/2014/09/view-result-return-type-in-mvc-50.html&quot; target=&quot;_blank&quot;&gt;View Result&lt;/a&gt;&lt;br /&gt;
 &lt;/li&gt;
&lt;li&gt; &lt;a href=&quot;http://ramchandr.blogspot.com/2014/09/partial-view-result-sample-web-app-in-mvc.html&quot; target=&quot;_blank&quot;&gt;Partial View Result with sample application&lt;/a&gt;&lt;br /&gt;
 &lt;/li&gt;
&lt;li&gt; &lt;a href=&quot;http://ramchandr.blogspot.com/2014/09/prevent-partial-view-to-access-directly-in-mvc.html&quot; target=&quot;_blank&quot;&gt;Prevent PartialView to access directly from the URL&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 24pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;RoadMap&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
In this article, you will get an idea of the following things.&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt; About JsonResult and its properties&lt;br /&gt;
 &lt;ul&gt;
&lt;li&gt; ContentEncoding&lt;br /&gt;
 &lt;/li&gt;
&lt;li&gt; ContentType&lt;br /&gt;
 &lt;/li&gt;
&lt;li&gt; Data&lt;br /&gt;
 &lt;/li&gt;
&lt;li&gt; JsonRequestBehavior&lt;br /&gt;
 &lt;/li&gt;
&lt;li&gt; MasJsonLength&lt;br /&gt;
 &lt;/li&gt;
&lt;li&gt; RecursionLimit&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt; Sample project with various scenarios using JsonResult:&lt;/li&gt;
&lt;/ol&gt;
&lt;ol&gt;&lt;ul&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
Send JSON content welcome note based on user type&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/ol&gt;
&lt;ol&gt;&lt;ul&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
Get the list of users in JSON Format&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/ol&gt;
&lt;ol&gt;&lt;ul&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
How to create JSON data at the client side and send it to the controller&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/ol&gt;
&lt;ol&gt;&lt;ul&gt;
&lt;li&gt; &lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
How to handle a huge amount of JSON Data&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/ol&gt;
&lt;ol start=&quot;3&quot;&gt;
&lt;li&gt; Unit Testing of JsonResult&lt;/li&gt;
&lt;/ol&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;About JsonResult and its properties&lt;/span&gt;&lt;/b&gt;&lt;/span&gt; &lt;br /&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
The
 JSON format is an open standard format. The format of data looks very 
easy to understand and the data objects consist of attribute-value 
pairs.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;ContentEncoding&lt;/span&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;:&lt;/span&gt;&lt;/b&gt; It helps to indicate the content encoding type, the default encoding for JSON is UTF-8.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;ContentType:&lt;/span&gt;&lt;/span&gt; &lt;/b&gt;It helps to indicate the content type. The default content type for JSON is application/json; charset=utf-8.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Note:&lt;/span&gt;&lt;/b&gt;
 ContentType and ContentEncoding are not necessary to mention when 
sending the data in JSON format as the HTTP headers are having a 
responsibility to tell the recipient what kind of content they&#39;re 
dealing with.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Data:&lt;/span&gt; &lt;/span&gt;&lt;/b&gt;This indicates what the content data is, that means what you will send in JSON format.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;JsonRequestBehavior:&lt;/span&gt; &lt;/b&gt;This
 property has two options. Those are AllowGet and DenyGet. The default 
option is DenyGet. When you send data in JSON format, using Get Request,
 it&#39;s necessary to specify the property as AllowGet otherwise it shows 
the error as “The request would be blocked since the JSON data is 
considered as sensitive data information”.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
&lt;b style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;MaxJsonLength:&lt;/span&gt;&lt;/b&gt;
 This helps to get or set the maximum JSON content length that you will 
send. The default value for this is 2097152 characters, that is equal to
 4 MB of Unicode string data. You can even increase the size based if 
needed, for that you will get an idea later in this article.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
&lt;b style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;RecursionLimit:&lt;/span&gt;&lt;/b&gt;
 Indicates the constraining number of object levels to process. The 
default value is 100. It means you can serialize the objects that are 
nested to a depth of 100 objects referencing each other. In a general 
scenario the default limit 100 is obviously sufficient when you deal 
with a JsonResult so there is no need to increase it even though you 
have the option to increase the limit if required.&lt;/div&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Sample Project with Various Scenarios by using JsonResult&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
Create a new project with the name JsonResultDemo and choose the template as MVC as shown in the following screen shots.&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/AVvXsEhPRaFu3UhuSpJ9qKn9fjnOVsZt2wOHpNSiuyZ6OmzCUFInyRjQeRqqsjnQ15Yzw6_quKGDmicPABTsNDswdy126DP4WNQSTB1FFcops6qsNnB0Xl_dLzc7UNvVXohi8A9SL1sYrw_pr0I/s1600/01-asp-dotnet-web-application.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPRaFu3UhuSpJ9qKn9fjnOVsZt2wOHpNSiuyZ6OmzCUFInyRjQeRqqsjnQ15Yzw6_quKGDmicPABTsNDswdy126DP4WNQSTB1FFcops6qsNnB0Xl_dLzc7UNvVXohi8A9SL1sYrw_pr0I/s1600/01-asp-dotnet-web-application.jpg&quot; height=&quot;391&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, click on the OK button then the displayed screen is as in the following. &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/AVvXsEjOYYIp4cs1QUsIEmEQB4pZlU2RbbqzWnecpHuth_AOJb3gLrAGOoRxYHAv00kf382hQC_7uwYQh02xmoNQctn-TWj1REqXg8pVlpw4x1FW2Vle5XnygNOCBafSeh-vHBJ4IOMvFv3KnwE/s1600/02-change-authentication.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjOYYIp4cs1QUsIEmEQB4pZlU2RbbqzWnecpHuth_AOJb3gLrAGOoRxYHAv00kf382hQC_7uwYQh02xmoNQctn-TWj1REqXg8pVlpw4x1FW2Vle5XnygNOCBafSeh-vHBJ4IOMvFv3KnwE/s1600/02-change-authentication.jpg&quot; height=&quot;478&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
As
 in the preceding template, you need to select the “Add Unit Tests” 
option as well. So It helps to create a Unit Test project and then again
 click on the OK button then the project will be created and the startup
 application page displayed like the following.&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/AVvXsEixyjDrEU5a848znKepbWqDuwvABEzz5s0oxxANRLAEsX6Z6owHTgxRiIVQ4T-TlipeXQ75XsmPYcwZ1bds4hdAIGx9F99W1A0ridyPuP8Cws-eskhLWIhf_hoZLoJBV7Ci2vUkK0oDNcQ/s1600/03-your-asp-application.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEixyjDrEU5a848znKepbWqDuwvABEzz5s0oxxANRLAEsX6Z6owHTgxRiIVQ4T-TlipeXQ75XsmPYcwZ1bds4hdAIGx9F99W1A0ridyPuP8Cws-eskhLWIhf_hoZLoJBV7Ci2vUkK0oDNcQ/s1600/03-your-asp-application.jpg&quot; height=&quot;364&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, add a controller and provide the name as “JsonDemoController” as in the following.&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/AVvXsEi4zv670jYYn0RX2CT9Fd3zc4alxcvlpPxsu4VBo-nUW2MDaj1f06F7kaGkUwoYTIUX0pxak5l8qOlVmDclk0vM5JCZBd6TsxVP9Zm_pOAk6WgDpeP5F6aoKY604tgWPocaNPR8P3rhWnE/s1600/04-json-demo-controller.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi4zv670jYYn0RX2CT9Fd3zc4alxcvlpPxsu4VBo-nUW2MDaj1f06F7kaGkUwoYTIUX0pxak5l8qOlVmDclk0vM5JCZBd6TsxVP9Zm_pOAk6WgDpeP5F6aoKY604tgWPocaNPR8P3rhWnE/s1600/04-json-demo-controller.jpg&quot; height=&quot;193&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Click on the Controller and then it wil open the popup window as in the following.&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/AVvXsEhUjwGRF1-7Mg30Firere6fWIb13FdyyTBJgQYnFvEDYosz66moWJFCM2oJzs5tG7PLugB-fFSiLDSgvkYpWz6rMoJnzj8o_pC2sJTFEOeBMifwETP1u_Zoaof9ohnQ4SHrSr45WRRfnoE/s1600/05-mvc5-controller.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhUjwGRF1-7Mg30Firere6fWIb13FdyyTBJgQYnFvEDYosz66moWJFCM2oJzs5tG7PLugB-fFSiLDSgvkYpWz6rMoJnzj8o_pC2sJTFEOeBMifwETP1u_Zoaof9ohnQ4SHrSr45WRRfnoE/s1600/05-mvc5-controller.jpg&quot; height=&quot;445&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Now
 click on the “Add” button and then it opens a popup to enter the name. 
So enter the name as “JsonDemoController” as shown in the screen shot.&lt;br /&gt;
&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/AVvXsEgGcnitUaquWJyacF4tBfKTP3tIvsLpBO2s3ohPgpse9SbmL-tupRQICMw0l4dkOeWu2zi-jKFArxK_AmvyOx5U45aKXvc5VgbgvSM7MTCI4OltqsIfwuDpTVn87adXPAcQljaUPDi_StQ/s1600/06-add-controller.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGcnitUaquWJyacF4tBfKTP3tIvsLpBO2s3ohPgpse9SbmL-tupRQICMw0l4dkOeWu2zi-jKFArxK_AmvyOx5U45aKXvc5VgbgvSM7MTCI4OltqsIfwuDpTVn87adXPAcQljaUPDi_StQ/s1600/06-add-controller.jpg&quot; height=&quot;141&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
After adding the controller to the project the controller page looks like the following.&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/AVvXsEgt-0N9pslvIWnvjAJbSe4NJ7HwMo2O1SKTHOngfsAgG6JHn31hW-GyXgm3oAx7Mqtpkh7jmkX7GaTE0EBaA28aaDUCc1SWac8nvOiTDcgztTt9xikOocWJUbiD-8DMSOYDmcGwFaaf_Ic/s1600/07-json-demo-controller.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgt-0N9pslvIWnvjAJbSe4NJ7HwMo2O1SKTHOngfsAgG6JHn31hW-GyXgm3oAx7Mqtpkh7jmkX7GaTE0EBaA28aaDUCc1SWac8nvOiTDcgztTt9xikOocWJUbiD-8DMSOYDmcGwFaaf_Ic/s1600/07-json-demo-controller.jpg&quot; height=&quot;420&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
Until
 now, you are done with the creation of the sample project template with
 the addition of one controller named “JsonDemoController”.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Scenario 1: Send JSON Content welcome note based on user type&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
In
 this scenario, you will learn how to send a simple welcome note message
 in JSON format from the controller. Now, replace the existing code with
 the following code in the JsonDemoController.cs file.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;using System;  
using System.Collections.Generic;  
using System.Text;  
using System.Web.Mvc;  
using System.Web.Script.Serialization;  
using JsonResultDemo.Models;  
  
namespace JsonResultDemo.Controllers  
{  
    public class JsonDemoController : Controller  
    {  
        #region ActionControllers  
  
        /// &lt;summary&gt;  
        /// Welcome Note Message  
        /// &lt;/summary&gt;  
        /// &lt;returns&gt;In a Json Format&lt;/returns&gt;  
        public JsonResult WelcomeNote()  
        {  
            bool isAdmin = false;  
            //TODO: Check the user if it is admin or normal user, 
            //(true-Admin, false- Normal user)  
            string output = isAdmin ? &quot;Welcome to the Admin User&quot; 
                            : &quot;Welcome to the User&quot;;  
  
            return Json(output, JsonRequestBehavior.AllowGet);  
        }  
     }  
}  
&lt;/pre&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
Then, build the application (F6) and then hit the F5 to run an application and then navigate to the following URL &lt;a href=&quot;http://localhost:49568/JsonDemo/WelcomeNote&quot;&gt;http://localhost:49568/JsonDemo/WelcomeNote&lt;/a&gt; (It might be a chance to get a different Port Id at your end).&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
Then the displayed screen looks like the following.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&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/AVvXsEiTsrCjVcfi-oMj_1zmWgdaYkyC401JBqaNuUP8juba9_Yb2DVZGJjPvPua8NxIURP3pQBwb3xxpKXs79YaQ1CoGxj6MS2Zk2dlnU6wjevMsP6NnS2WvPNrj8gqJo86MGs8MIOMq0i4VCA/s1600/08-Welcome-Note.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTsrCjVcfi-oMj_1zmWgdaYkyC401JBqaNuUP8juba9_Yb2DVZGJjPvPua8NxIURP3pQBwb3xxpKXs79YaQ1CoGxj6MS2Zk2dlnU6wjevMsP6NnS2WvPNrj8gqJo86MGs8MIOMq0i4VCA/s1600/08-Welcome-Note.jpg&quot; height=&quot;192&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
In this scenario, you now have an idea of how to send a simple string in JSON format.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Scenario 2: Get the list of users in JSON Format&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
In this scenario you will send a list of users in JSON format.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;b style=&quot;font-size: 12pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 1:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; Add a class file “UserModel.cs” like the following.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&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/AVvXsEi5GGH-h7eexpqQpUSgcWYjURahmFxAffRbp8SMKMgJIGcerwD6PylVtXUpyKg9lewOmx3vje2J1_Cyci4uKRDHPMiw0HdgAzH18lK5H-vMN34iewBxfHHzgh6PoDccrufqubKLBG2n9rY/s1600/09-add-new-controller.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi5GGH-h7eexpqQpUSgcWYjURahmFxAffRbp8SMKMgJIGcerwD6PylVtXUpyKg9lewOmx3vje2J1_Cyci4uKRDHPMiw0HdgAzH18lK5H-vMN34iewBxfHHzgh6PoDccrufqubKLBG2n9rY/s1600/09-add-new-controller.jpg&quot; height=&quot;355&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
Click on “Class” and then the displayed link is as the following.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&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/AVvXsEgyUUorokFS8euhRz7jY1SP4BawGYsIhM-Huyyke0hmk65las1dBdtQCWxDBWXNHle-y8nd2VocoCydJOcDkwR3EBgyQfHAFmHbVuthfkp8z2Nfw_OCfA3Z3y_JyY8MJ7dp98WDqTA_Mds/s1600/10-add-new-class.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgyUUorokFS8euhRz7jY1SP4BawGYsIhM-Huyyke0hmk65las1dBdtQCWxDBWXNHle-y8nd2VocoCydJOcDkwR3EBgyQfHAFmHbVuthfkp8z2Nfw_OCfA3Z3y_JyY8MJ7dp98WDqTA_Mds/s1600/10-add-new-class.jpg&quot; height=&quot;396&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Enter the name as “UserModel.cs” and then click on the Add button.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;b style=&quot;font-size: 12pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 2:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; Update the code in UserMode.cs with the following code.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Web;  
  
namespace JsonResultDemo.Models  
{  
    public class UserModel  
    {  
        public int UserId { get; set; }  
        public string UserName { get; set; }  
        public string Company { get; set; }  
    }  
}  
&lt;/pre&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;b&gt;S&lt;span style=&quot;font-size: 12pt;&quot;&gt;tep 3:&amp;nbsp;&lt;/span&gt;&lt;/b&gt;Add one method named GetUsers in the JsonDemoController.cs file that will return the list of sample users.&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;        
        /// &lt;summary&gt;  
        /// Get the Users  
        /// &lt;/summary&gt;  
        /// &lt;returns&gt;&lt;/returns&gt;  
        private List&lt;usermodel&gt; GetUsers()  
        {  
            var usersList = new List&lt;usermodel&gt;  
            {  
                new UserModel  
                {  
                    UserId = 1,  
                    UserName = &quot;Ram&quot;,  
                    Company = &quot;Mindfire Solutions&quot;  
                },  
                new UserModel  
                {  
                    UserId = 1,  
                    UserName = &quot;chand&quot;,  
                    Company = &quot;Mindfire Solutions&quot;  
                },  
                new UserModel  
                {  
                    UserId = 1,  
                    UserName = &quot;Abc&quot;,  
                    Company = &quot;Abc Solutions&quot;  
                }  
            };  
  
            return usersList;  
        }&lt;/usermodel&gt;&lt;/usermodel&gt;&lt;/pre&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 4:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; Create one Action Controller method named GetUsersData with the following code in the JsonDemoController.cs file.&amp;nbsp;&amp;nbsp;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;/// &lt;summary&gt;  
/// Get tthe Users data in Json Format  
/// &lt;/summary&gt;  
/// &lt;returns&gt;&lt;/returns&gt;  
public JsonResult GetUsersData()  
{  
    var users = GetUsers();  
    return Json(users, JsonRequestBehavior.AllowGet);  
}  
&lt;/pre&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 5:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; Run the application with this URL &lt;a href=&quot;http://localhost:49568/JsonDemo/GetUsersData&quot;&gt;http://localhost:49568/JsonDemo/GetUsersData&lt;/a&gt; then the output looks like the following.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&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/AVvXsEifGehpaRoc0lNtN57LigwQI_gEZ5ujtcAhZOJZTpJQMsfVhnZWiR8HGWBJHjY4VBzw1F1O_KkFD1Pr7EYRD1qrK2WE_JRFmcaiPo61JY5ZdEf_ychTVZScf1Uw8u_Qc1sYAnU65suKb8M/s1600/11-getuser-data.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEifGehpaRoc0lNtN57LigwQI_gEZ5ujtcAhZOJZTpJQMsfVhnZWiR8HGWBJHjY4VBzw1F1O_KkFD1Pr7EYRD1qrK2WE_JRFmcaiPo61JY5ZdEf_ychTVZScf1Uw8u_Qc1sYAnU65suKb8M/s1600/11-getuser-data.jpg&quot; height=&quot;201&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Scenario 3 : Create JSON data at the client side and send content to the controller&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
In
 this scenario, you will create JSON data at the client side and then 
that data will be sent to the Controller action. The controller action 
request type is HttpPost.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 1:&lt;/span&gt; &lt;/span&gt;&lt;/b&gt;Create one Action controller method named Sample like the following in the JsonDemoController.cs file.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;/// &lt;summary&gt;  
/// Sample View  
/// &lt;/summary&gt;  
/// &lt;returns&gt;&lt;/returns&gt;  
public ActionResult Sample()  
{  
    return View();  
}  
&lt;/pre&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 2:&lt;/span&gt;&lt;/b&gt;&amp;nbsp;Create
 a View file named “Sample.cshtml” by right-clicking on View() in the 
Sample action controller method then click on “Add View” in the Sample 
action like the following.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&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/AVvXsEg6NiKz9Agl4V10FCeEiPC14O9nJ30gs7vfu4pVC2QSTByexOJBVzc0S9L4yWW9uAoFEBVuCChPoZRLLz-hSn4NKi08hL0JNT0pnYHAJDgTptraDya2GTC4PIfAE6zw3jK9OXvUxUn50qM/s1600/12-json-demo-controller-code.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6NiKz9Agl4V10FCeEiPC14O9nJ30gs7vfu4pVC2QSTByexOJBVzc0S9L4yWW9uAoFEBVuCChPoZRLLz-hSn4NKi08hL0JNT0pnYHAJDgTptraDya2GTC4PIfAE6zw3jK9OXvUxUn50qM/s1600/12-json-demo-controller-code.jpg&quot; height=&quot;179&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
By clicking on Add View it opens a popup and deselects the &quot;Use a layout page&quot; option. It then should look as in the following.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&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/AVvXsEgu6tRnM7kaXT8vc4ISrs_dkYduW7VhRLTCQhrqLErIIaEoUYG6nS8j-AkKCyhITZOixDL2aAFlSzqR0Xxx52KF2OrYTAtrbjPbSXX6GSbDMyJiOcHMT-cJSaMWEFnCpqWBGGM5TGN2qrU/s1600/13-add-new-view.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgu6tRnM7kaXT8vc4ISrs_dkYduW7VhRLTCQhrqLErIIaEoUYG6nS8j-AkKCyhITZOixDL2aAFlSzqR0Xxx52KF2OrYTAtrbjPbSXX6GSbDMyJiOcHMT-cJSaMWEFnCpqWBGGM5TGN2qrU/s1600/13-add-new-view.jpg&quot; height=&quot;395&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
Now, click on the OK button then the sample.cshtml file will be created.&lt;/div&gt;
&lt;div align=&quot;justify&quot;&gt;
&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;Step 3:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt; Replace it with the following cshtml code in the sample.cshtml file.&lt;/div&gt;
&lt;div align=&quot;justify&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;@{  
    Layout = null;  
} 
  
&lt;html&gt;  
    &lt;head&gt;  
          
        &lt;title&gt;Create Sample JSON Data and send it to controller&lt;/title&gt;  
    &lt;/head&gt;  
    &lt;body&gt;  
        &lt;div&gt;
  
            &lt;label&gt;Create Sample User JSON Data and send it to controller&lt;/label&gt;

  
            &lt;input id=&quot;btnUpdateUserDetail&quot; onclick=&quot;UpdateUserDetail();&quot; type=&quot;button&quot; value=&quot;Update User Detail&quot; /&gt;  
        &lt;/div&gt;
&lt;/body&gt;  
&lt;/html&gt;  
&lt;script src=&quot;~/Scripts/jquery-1.10.2.min.js&quot;&gt;&lt;/script&gt;  
&lt;script lang=&quot;en&quot; type=&quot;text/javascript&quot;&gt;  
    function UpdateUserDetail() {  
        var usersJson = GetSampleUsersList();  
        var getReportColumnsParams = {  
            &quot;usersJson&quot;: usersJson  
        };  
        $.ajax({  
            type: &quot;POST&quot;,  
            traditional: true,  
            async: false,  
            cache: false,  
            url: &#39;/JsonDemo/UpdateUsersDetail&#39;,  
            context: document.body,  
            data: getReportColumnsParams,  
            success: function (result) {  
                alert(result);  
            },  
            error: function (xhr) {  
                //debugger;  
                console.log(xhr.responseText);  
                alert(&quot;Error has occurred..&quot;);  
            }  
        });  
    }  
    function GetSampleUsersList() {  
        var userDetails = {};  
        var usersList = [];  
        for (var i = 1; i &lt;= 3; i++) {  
            userDetails[&quot;UserId&quot;] = i;  
            userDetails[&quot;UserName&quot;] = &quot;User- &quot; + i;  
            userDetails[&quot;Company&quot;] = &quot;Company- &quot; + i;  
            usersList.push(userDetails);  
        }  
        return JSON.stringify(usersList);  
    }  
&lt;/script&gt;
&lt;/pre&gt;
&lt;div align=&quot;justify&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
The following is a brief description of the Sample.cshtml file:&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;The HTML body contains a label, about, to describe the functionality and one input button with an onclick of &lt;/span&gt;the UpdateUserDetail() function.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;The JavaScript part contains the jQuery reference and it contains two functions. &lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;GetSampleUsersList() will return the sample users in a stringified JSON format.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;UpdateUserDetail() sends the ajax request of post type for JsonDemoController with UpdateUserDetail action.&lt;/li&gt;
&lt;/ul&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 4:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;
 A Create Action method named UpdateUsersDetail in the 
JsonDemoController as in the following and put a breakpoint in this 
method on the first line of code to help to trace the details.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;/// &lt;summary&gt;  
/// Update the user details  
/// &lt;/summary&gt;  
/// &lt;param name=&quot;usersJson&quot; /&gt;users list in JSON Format  
/// &lt;returns&gt;&lt;/returns&gt;  
[HttpPost]  
public JsonResult UpdateUsersDetail(string usersJson)  
{  
    var js = new JavaScriptSerializer();  
    UserModel[] user = js.Deserialize&lt;usermodel&gt;(usersJson);  
  
    //TODO: user now contains the details, you can do required operations  
    return Json(&quot;User Details are updated&quot;);  
}
&lt;/usermodel&gt;&lt;/pre&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 5:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; Build and run the application (hit F5) with the URL ( &lt;a href=&quot;http://localhost:49568/JsonDemo/Sample&quot;&gt;http://localhost:49568/JsonDemo/Sample&lt;/a&gt; ) then the resultant screen looks like the following.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&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/AVvXsEgSs33Z_LNCOvJj_Zz-Xkpphx48E7-DZ2a3EWLxYVvESlegUum7rzai6p2f-lEgAzkgqbsHxU3cYjnKqTqADHy2Uc_tj08uAVXANAFd-JWOGz8FnTLRyqdAiURRpIH1oewRKtYKlD9S22g/s1600/14-create-sample-user-json-data.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSs33Z_LNCOvJj_Zz-Xkpphx48E7-DZ2a3EWLxYVvESlegUum7rzai6p2f-lEgAzkgqbsHxU3cYjnKqTqADHy2Uc_tj08uAVXANAFd-JWOGz8FnTLRyqdAiURRpIH1oewRKtYKlD9S22g/s1600/14-create-sample-user-json-data.jpg&quot; height=&quot;209&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 6:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;
 Now, click on the “Update User Detail” button as it appears in the 
aforesaid screenshot. Then the resultant screen looks like the 
following.&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&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/AVvXsEgKeYHoHA1h3JUgCjTfz9qDmbrLFZ3vd8SEIFqeYJrzXXI0ZfyUrNVjeCdkonNfp0G_Ug77WBEij1I6xv8ttr1x7DmEqp585qcqIojqqffscRkpPf_sdjPy5noevv2qzReqGOtZwaQBQkQ/s1600/15-update-user-detail.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKeYHoHA1h3JUgCjTfz9qDmbrLFZ3vd8SEIFqeYJrzXXI0ZfyUrNVjeCdkonNfp0G_Ug77WBEij1I6xv8ttr1x7DmEqp585qcqIojqqffscRkpPf_sdjPy5noevv2qzReqGOtZwaQBQkQ/s1600/15-update-user-detail.jpg&quot; height=&quot;179&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 7:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;
 Just review the preceding image, you can identify that you are able to 
send the JSON data to the controller action from the client side and as 
well as you have deserialized the JSON data and assigned that data to 
the UserModel entity.&lt;/div&gt;
&lt;div align=&quot;justify&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Scenario 4: How to handle huge amount of JSON Data&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div align=&quot;justify&quot; style=&quot;font-weight: normal;&quot;&gt;
In
 this scenario, you will get an idea of how to send a huge amount of 
JSON Data. Actually in certain scenarios you must send a huge amount of 
data from a controller to a view. In that case the following example 
will be helpful to you.&lt;/div&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 1:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; Create one method named GetUsersHugeData() as in the following. It just helps to generate sample user data.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;/// &lt;summary&gt;  
/// Get the huge list of users  
/// &lt;/summary&gt;  
/// &lt;returns&gt;&lt;/returns&gt;  
private List&lt;usermodel&gt; GetUsersHugeData()  
{  
 var usersList = new List&lt;usermodel&gt;();  
 UserModel user;  
 for (int i = 1; i &amp;lt; 51000; i++)  
 {  
  user = new UserModel  
  {  
   UserId = i,  
   UserName = &quot;User-&quot;+i,  
   Company = &quot;Company-&quot;+i  
  };  
  usersList.Add(user);  
 }  

 return usersList;  
} 
&lt;/usermodel&gt;&lt;/usermodel&gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 2:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; Create an Action method named GetUsersHugeList() like the following in the JsonDemoController.cs file.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;    /// &lt;summary&gt;  
    /// Get the huge list of Users  
    /// &lt;/summary&gt;  
    /// &lt;returns&gt;&lt;/returns&gt;  
    public JsonResult GetUsersHugeList()  
    {  
        var users = GetUsersHugeData();  
        return Json(users, JsonRequestBehavior.AllowGet);  
    } 


&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-size: 12pt;&quot;&gt;&lt;b&gt;Step 3:&amp;nbsp;&lt;/b&gt;&lt;/span&gt;Now, build and run (hit F5) the application with the URL ( &lt;a href=&quot;http://localhost:49568/JsonDemo/GetUsersHugeList&quot; style=&quot;font-weight: normal;&quot;&gt;http://localhost:49568/JsonDemo/GetUsersHugeList&lt;/a&gt; ) then the error screen appears like the following.&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/AVvXsEhYVLp-7fcWsF9VMTCt5wSpkDqftQn8_cPA8UOjCesFSEwHZ8KrcXk0CazAsWy4leoqMh_iDsclLxPoBuYf4qOpSWl46DPD1ZlmK-bR8a57Orjn8f4I-vtmfZNTOWEJoHOtyLobqjUuGYo/s1600/16-serve-error.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhYVLp-7fcWsF9VMTCt5wSpkDqftQn8_cPA8UOjCesFSEwHZ8KrcXk0CazAsWy4leoqMh_iDsclLxPoBuYf4qOpSWl46DPD1ZlmK-bR8a57Orjn8f4I-vtmfZNTOWEJoHOtyLobqjUuGYo/s1600/16-serve-error.jpg&quot; height=&quot;282&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b style=&quot;font-size: 12pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 4:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;
 To fix the preceding error add the following code in the 
JsonDemoController file. This methods helps to update the MaxJsonLength 
property value to Int32.MaxValue.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;/// &lt;summary&gt;  
/// Override the JSON Result with Max integer JSON lenght  
/// &lt;/summary&gt;  
/// &lt;param name=&quot;data&quot; /&gt;Data  
/// &lt;param name=&quot;contentType&quot; /&gt;Content Type  
/// &lt;param name=&quot;contentEncoding&quot; /&gt;Content Encoding  
/// &lt;param name=&quot;behavior&quot; /&gt;Behavior  
/// &lt;returns&gt;As JsonResult&lt;/returns&gt;  
protected override JsonResult Json(object data, string contentType,  
    Encoding contentEncoding, JsonRequestBehavior behavior)  
{  
    return new JsonResult()  
    {  
        Data = data,  
        ContentType = contentType,  
        ContentEncoding = contentEncoding,  
        JsonRequestBehavior = behavior,  
        MaxJsonLength = Int32.MaxValue  
    };  
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
In
 the same way, you can increase the RecursionLimit property value. Also 
if you require JsonData with a depth (nested levels) greater than 100.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 5:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; Now, build and run (hit F5) the application with the URL ( &lt;a href=&quot;http://localhost:49568/JsonDemo/GetUsersHugeList&quot;&gt;http://localhost:49568/JsonDemo/GetUsersHugeList&lt;/a&gt; ) and then the huge data result appears instead of an error.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&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/AVvXsEjEQLUABnNWyIWtTGrs0BwIkZklN7d8yxaL87b9gAc5O1bXb-r7QPOYkanuFEnRMQL4Fw73Pk6twAtwclU_aqqBpIcdW9Jf-SqB3R5EXgzSJ_Oyb9iOTkTOGfFykkD3K-VXueivzVUxDSQ/s1600/17-getusers-hugelist.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEQLUABnNWyIWtTGrs0BwIkZklN7d8yxaL87b9gAc5O1bXb-r7QPOYkanuFEnRMQL4Fw73Pk6twAtwclU_aqqBpIcdW9Jf-SqB3R5EXgzSJ_Oyb9iOTkTOGfFykkD3K-VXueivzVUxDSQ/s1600/17-getusers-hugelist.jpg&quot; height=&quot;323&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
I
 have provided the formatted complete code for the JsonDemoController.cs
 file for what you have done until now in the aforesaid scenarios. &lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;using System;  
using System.Collections.Generic;  
using System.Text;  
using System.Web.Mvc;  
using System.Web.Script.Serialization;  
using JsonResultDemo.Models;  
  
namespace JsonResultDemo.Controllers  
{  
    public class JsonDemoController : Controller  
    {  
        #region ActionControllers  
  
        /// &lt;summary&gt;  
        /// Welcome Note Message  
        /// &lt;/summary&gt;  
        /// &lt;returns&gt;In a JSON Format&lt;/returns&gt;  
        public JsonResult WelcomeNote()  
        {  
            bool isAdmin = false;  
            //TODO: Check the user if it is admin or normal user, (true-Admin, false- Normal user)  
            string output = isAdmin ? &quot;Welcome to the Admin User&quot; : &quot;Welcome to the User&quot;;  
  
            return Json(output, JsonRequestBehavior.AllowGet);  
        }  
  
        /// &lt;summary&gt;  
        /// Get tthe Users data in JSON Format  
        /// &lt;/summary&gt;  
        /// &lt;returns&gt;&lt;/returns&gt;  
        public JsonResult GetUsersData()  
        {  
            var users = GetUsers();  
            return Json(users, JsonRequestBehavior.AllowGet);  
        }  
  
        /// &lt;summary&gt;  
        /// Sample View  
        /// &lt;/summary&gt;  
        /// &lt;returns&gt;&lt;/returns&gt;  
        public ActionResult Sample()  
        {  
            return View();  
        }  
  
        /// &lt;summary&gt;  
        /// Update the user details  
        /// &lt;/summary&gt;  
        /// &lt;param name=&quot;usersJson&quot; /&gt;users list in JSON Format  
        /// &lt;returns&gt;&lt;/returns&gt;  
        [HttpPost]  
        public JsonResult UpdateUsersDetail(string usersJson)  
        {  
            var js = new JavaScriptSerializer();  
            UserModel[] user = js.Deserialize&lt;usermodel&gt;(usersJson);  
  
            //TODO: user now contains the details, you can do required operations  
            return Json(&quot;User Details are updated&quot;);  
        }  
          
        /// &lt;summary&gt;  
        /// Get the huge list of Users  
        /// &lt;/summary&gt;  
        /// &lt;returns&gt;&lt;/returns&gt;  
        public JsonResult GetUsersHugeList()  
        {  
            var users = GetUsersHugeData();  
            return Json(users, JsonRequestBehavior.AllowGet);  
        }  
 
        #endregion  
 
 
        #region Methods  
  
        /// &lt;summary&gt;  
        /// Get the Users  
        /// &lt;/summary&gt;  
        /// &lt;returns&gt;&lt;/returns&gt;  
        private List&lt;usermodel&gt; GetUsers()  
        {  
            var usersList = new List&lt;usermodel&gt;  
            {  
                new UserModel  
                {  
                    UserId = 1,  
                    UserName = &quot;Ram&quot;,  
                    Company = &quot;Mindfire Solutions&quot;  
                },  
                new UserModel  
                {  
                    UserId = 1,  
                    UserName = &quot;chand&quot;,  
                    Company = &quot;Mindfire Solutions&quot;  
                },  
                new UserModel  
                {  
                    UserId = 1,  
                    UserName = &quot;Abc&quot;,  
                    Company = &quot;Abc Solutions&quot;  
                }  
            };  
  
            return usersList;  
        }  
  
        /// &lt;summary&gt;  
        /// Get the huge list of users  
        /// &lt;/summary&gt;  
        /// &lt;returns&gt;&lt;/returns&gt;  
        private List&lt;usermodel&gt; GetUsersHugeData()  
        {  
            var usersList = new List&lt;usermodel&gt;();  
            UserModel user;  
            for (int i = 1; i &amp;lt; 51000; i++)  
            {  
                user = new UserModel  
                {  
                    UserId = i,  
                    UserName = &quot;User-&quot;+i,  
                    Company = &quot;Company-&quot;+i  
                };  
                usersList.Add(user);  
            }  
  
            return usersList;  
        }  
  
        /// &lt;summary&gt;  
        /// Override the Json Result with Max integer JSON lenght  
        /// &lt;/summary&gt;  
        /// &lt;param name=&quot;data&quot; /&gt;Data  
        /// &lt;param name=&quot;contentType&quot; /&gt;Content Type  
        /// &lt;param name=&quot;contentEncoding&quot; /&gt;Content Encoding  
        /// &lt;param name=&quot;behavior&quot; /&gt;Behavior  
        /// &lt;returns&gt;As JsonResult&lt;/returns&gt;  
        protected override JsonResult Json(object data, string contentType,  
            Encoding contentEncoding, JsonRequestBehavior behavior)  
        {  
            return new JsonResult()  
            {  
                Data = data,  
                ContentType = contentType,  
                ContentEncoding = contentEncoding,  
                JsonRequestBehavior = behavior,  
                MaxJsonLength = Int32.MaxValue  
            };  
        }  
 
        #endregion  
    }  
}
&lt;/usermodel&gt;&lt;/usermodel&gt;&lt;/usermodel&gt;&lt;/usermodel&gt;&lt;/usermodel&gt;&lt;/pre&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
You
 now have an idea of how to use a JsonResult type in MVC application 
with various scenarios. Now, it&#39;s time to test the controller action 
methods using the JsonDemoController.Test project.&lt;/div&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Unit Testing the JsonResult in MVC&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
The
 main feature of MVC applications is it supports&amp;nbsp;the Test Data 
Driven (TDD) approach. Since the Controller file is just a kind of class
 file, it&#39;s easy to implement the Test methods in the Test Project. Now 
you will learn how to test the JsonResult methods in the test project.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 1:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; Add a class file named “JsonDemoControllerTest.cs” to the JsonResultDemo.Tests projects like the following.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&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/AVvXsEiHOHbb1KfA66h-rp57Tgk__YaW1Y_zNo-tBESIMiOOpu1GIgJ8c6maSOlY_xvcQRJ9dZKm5MKPXks6SOvBQJH_L1S9J_M26VZT3WAZrsCXn7PovNONsPoGmQmPWVLV5EC8Ru9voQo_5BA/s1600/18-controller.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHOHbb1KfA66h-rp57Tgk__YaW1Y_zNo-tBESIMiOOpu1GIgJ8c6maSOlY_xvcQRJ9dZKm5MKPXks6SOvBQJH_L1S9J_M26VZT3WAZrsCXn7PovNONsPoGmQmPWVLV5EC8Ru9voQo_5BA/s1600/18-controller.jpg&quot; height=&quot;424&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
Click on “Class” to open a popup like the following and then update the name as “JsonDemoControllerTest.cs”.&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&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/AVvXsEii03kKM23MuRqelbY8OFhWbFO8LSaS3E58xXXgMvJb502JyDp42Bn-vfeBwM30AtoNt_rVfdyrcgyNPul8-ExWJG7X6yvy9r1Lw4osHNE0gZTkcD2S3WouUXjPFCeZmJpM985u3Gb8JAs/s1600/19-json-demo-controller-test.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEii03kKM23MuRqelbY8OFhWbFO8LSaS3E58xXXgMvJb502JyDp42Bn-vfeBwM30AtoNt_rVfdyrcgyNPul8-ExWJG7X6yvy9r1Lw4osHNE0gZTkcD2S3WouUXjPFCeZmJpM985u3Gb8JAs/s1600/19-json-demo-controller-test.jpg&quot; height=&quot;388&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 2:&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;After clicking on the “Ok” button then the screen result looks like the following.&lt;/span&gt;&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/AVvXsEgVqk5tHIoijneKcpvXse5bcU4FyqEX-OSNy4Rf3Bjl_6ljwB1ldEbKIaRnU4VHYLio4BdbHhTIbPDqBtDpsiYXq-oVGDiae0cTz3tsebRTsq6nqIyxzGxmXhHmYF0MZclaUcW0PSjgdSY/s1600/20-json-demo-controller-test-coding.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgVqk5tHIoijneKcpvXse5bcU4FyqEX-OSNy4Rf3Bjl_6ljwB1ldEbKIaRnU4VHYLio4BdbHhTIbPDqBtDpsiYXq-oVGDiae0cTz3tsebRTsq6nqIyxzGxmXhHmYF0MZclaUcW0PSjgdSY/s1600/20-json-demo-controller-test-coding.jpg&quot; height=&quot;312&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 3:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; Now, replace the existing code in the file JsonDeomControllerTest.cs with the following code.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;using System;  
using System.Web.Mvc;  
using Microsoft.VisualStudio.TestTools.UnitTesting;  
using JsonResultDemo.Controllers;  
  
namespace JsonResultDemo.Tests.Controllers  
{  
    [TestClass]  
    public class JsonDemoControllerTest  
    {  
        [TestMethod]  
        public void WelcomeNote()  
        {  
            JsonDemoController controller = new JsonDemoController();  
  
            JsonResult result = controller.WelcomeNote();  
            string msg = Convert.ToString(result.Data);  
            // Assert  
            Assert.AreEqual(&quot;Welcome to the User&quot;, msg);  
        }  
    }  
}  
&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;b&gt;Brief Note about TestMethod of WelcomeNote()&lt;/b&gt;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;Create an object for JsonDemoController.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;Save
 the result of JsonDemoController controller method “WelcomeNote” method
 result in the “result” parameter of the type JsonResult.&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;The string “msg” is assigned with the value from the Json Result (result.Data).&lt;br /&gt;&lt;br /&gt; &lt;/li&gt;
&lt;li&gt;In
 this step, you are checking the expected output with the actual output 
using the Assert method. In a similar way the Assert Method provides 
other options like AreNotEqual, AreSame, IsNotNull and so on.&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 4:&lt;/span&gt;&lt;/span&gt;&lt;/b&gt; Right-click on the WelcomeNote method and click on “Run Unit Tests” then the screen result looks like the following.&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/AVvXsEhJxz_lpJ8SNdXSRJI-f9oxKdTQ_E9L4R1xeD_Dgxbswzdxehyi4IfPzi_NqbzGibaisRCwZDR2QWCvwqzT0FOnTf-w6ng4pqFXGLuRA5FC6_VtuHvDrDGuJg2s6xUpNRhohO6npz-bArY/s1600/21-unit-test-result.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhJxz_lpJ8SNdXSRJI-f9oxKdTQ_E9L4R1xeD_Dgxbswzdxehyi4IfPzi_NqbzGibaisRCwZDR2QWCvwqzT0FOnTf-w6ng4pqFXGLuRA5FC6_VtuHvDrDGuJg2s6xUpNRhohO6npz-bArY/s1600/21-unit-test-result.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 5:&lt;/span&gt; &lt;/span&gt;&lt;/b&gt;You
 can also do the “Run Tests” by the clicking of (Ctrl +R, T). Then you 
can view the results in Test Explorer like the following.&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/AVvXsEhy6TFo2B1vW9ws_47aRIKAnxU9-PL8AOIsJ2vXdI2GVb2GQO56T7HekAdFBE0wnW2EJ7xXoZMevWpkQ1dpUANhWppiF7kQ3xCdtruDluaDnVlLg0v9z0a6BE6BoefeQ7yo8hy5qjtYouY/s1600/22-test-explorer.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhy6TFo2B1vW9ws_47aRIKAnxU9-PL8AOIsJ2vXdI2GVb2GQO56T7HekAdFBE0wnW2EJ7xXoZMevWpkQ1dpUANhWppiF7kQ3xCdtruDluaDnVlLg0v9z0a6BE6BoefeQ7yo8hy5qjtYouY/s1600/22-test-explorer.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;&lt;span style=&quot;font-size: 12pt;&quot;&gt;Step 6:&lt;/span&gt; &lt;/span&gt;&lt;/b&gt;As
 you noticed in the Test Explorer screen shot it contains so many 
options like “Run All” and Run the selected/required options. You can 
try with those and will get an idea of it easily.&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/AVvXsEga5y3gzQyD_wvX3fJQLay-16e4I5PqzLK7HhIU-Dh98B5QM0joj_2Hz0IZ84BB6dThqeMK45wDk0uGqU4QDBC2SZ7PO-KgfNlZZYEDYdM3OXS7IkD0fLcF2HKYEGrGvtmUpDedjrGdb_k/s1600/23-test-explorer-result.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEga5y3gzQyD_wvX3fJQLay-16e4I5PqzLK7HhIU-Dh98B5QM0joj_2Hz0IZ84BB6dThqeMK45wDk0uGqU4QDBC2SZ7PO-KgfNlZZYEDYdM3OXS7IkD0fLcF2HKYEGrGvtmUpDedjrGdb_k/s1600/23-test-explorer-result.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
In
 a similar way, you can create more test methods and it will be helpful 
to check the functionality in various cases since it provides correct 
results or not.&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Note:&lt;/b&gt; you can download the preceding discussed sample project from the link &lt;a href=&quot;https://drive.google.com/file/d/0B895m2cC0Xzed1pBTncyWTZLS1E/view?usp=sharing&quot; target=&quot;_blank&quot;&gt;Source Code&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b style=&quot;font-size: 18pt;&quot;&gt;&lt;span style=&quot;font-size: 14pt;&quot;&gt;Conclusion&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;font-weight: normal; text-align: justify;&quot;&gt;
I
 hope this article gives you an idea of JsonResult, JsonResult 
Properties, the usage of JsonResult with various scenarios and how can 
you test the JsonResult using the Test Project.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Please provide your valuable suggestions and comments on this.&lt;/div&gt;
&lt;span class=&quot;keyword&quot;&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/2077494225607632656/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2014/10/jsonresult-type-in-mvc.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/2077494225607632656'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/2077494225607632656'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2014/10/jsonresult-type-in-mvc.html' title='JsonResult Type in MVC'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/AVvXsEhPRaFu3UhuSpJ9qKn9fjnOVsZt2wOHpNSiuyZ6OmzCUFInyRjQeRqqsjnQ15Yzw6_quKGDmicPABTsNDswdy126DP4WNQSTB1FFcops6qsNnB0Xl_dLzc7UNvVXohi8A9SL1sYrw_pr0I/s72-c/01-asp-dotnet-web-application.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-3452880582109146117</id><published>2014-09-20T17:49:00.000+05:30</published><updated>2014-09-20T17:58:00.075+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="MVC"/><category scheme="http://www.blogger.com/atom/ns#" term="MVC 5.0"/><category scheme="http://www.blogger.com/atom/ns#" term="PartialViewResult"/><title type='text'>Prevent Partial view to access directly in MVC</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;About:&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
As I discussed in earlier &lt;a href=&quot;http://ramchandr.blogspot.com/2014/09/partial-view-result-sample-web-app-in-mvc.html&quot; target=&quot;_blank&quot;&gt;blog post&lt;/a&gt;,
PartialView is mostly used as a type of user control. So, The partial
view result should be used in other pages like a child Request and it
should not be accessible by direct Route Url.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
By Default, PartialViewResult
controller will be accessible through Route Url. But, you can
restrict or prvent access by just adding a one attribute above to
that controller action method named as “&lt;b&gt;[ChildActionOnly]&lt;/b&gt;”.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;Example:&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
Now, you can check it out by  the example,
Just add the below lines of code in the controller action method in
sample MVC application.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;    public class DemoController : Controller
    {
        /// &lt;summary&gt;
        /// Demo Partial Result
        /// &lt;/summary&gt;
        /// &lt;returns&gt;&lt;/returns&gt;
        public ActionResult DemoPartialResult()
        {
            return PartialView(&quot;_Demo&quot;);
        }
    }
&lt;/pre&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
Now, you create a partial view named as &quot;_Demo.cshtml&quot; with the template as &quot;Empty (without model) &quot; than add any sample text in that parital view.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
Now, If you run the application it
would accessible like the below.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYKwRZlXH9LeHNh8C9VqLuztHVVMB8SG7__k3u9uI-a8RFm5LLDAciskY7KL_ZIz6kfW_8TXBjtUZfVGgVxUvoWLGWfk7t3WoSk7nnkPIFs4Cro8yL_qSPYQvlsS0cbGvrs0fdC58Euz0/s1600/01-Partial-view-display.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYKwRZlXH9LeHNh8C9VqLuztHVVMB8SG7__k3u9uI-a8RFm5LLDAciskY7KL_ZIz6kfW_8TXBjtUZfVGgVxUvoWLGWfk7t3WoSk7nnkPIFs4Cro8yL_qSPYQvlsS0cbGvrs0fdC58Euz0/s1600/01-Partial-view-display.png&quot; height=&quot;216&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
But, If you add the attribute named as
“[ChildActionOnly]” then it does not allow us to access directly
from the URL. The code block looks like the below.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;        /// &lt;summary&gt;
        /// Demo Partial Result
        /// &lt;/summary&gt;
        /// &lt;returns&gt;&lt;/returns&gt;
        [ChildActionOnly]
        public ActionResult DemoPartialResult()
        {
            return PartialView(&quot;_Demo&quot;);
        }
&lt;/pre&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
Now,If you are trying to access from the
URL, It shows the error like the below.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvHLeXhezsi3vi-F4RxY7xcZ5JAa3nFlIbyYwTHcUiaq0tKikbCnSxPsxBXzT99-YtjLYuxpif8tO1iHVFBpzWEB_GrpDhqhOnbt3rK3VmYtr82Xxk21qmT34rXZUMDK-slEhYrLQRGAI/s1600/02-Partial-view-direct-access.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvHLeXhezsi3vi-F4RxY7xcZ5JAa3nFlIbyYwTHcUiaq0tKikbCnSxPsxBXzT99-YtjLYuxpif8tO1iHVFBpzWEB_GrpDhqhOnbt3rK3VmYtr82Xxk21qmT34rXZUMDK-slEhYrLQRGAI/s1600/02-Partial-view-direct-access.png&quot; height=&quot;162&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
Event, if you can&#39;t access the Partial
View result action method from ajax call as well.&lt;br /&gt;
For Example, The ajax call, you defined in the code like the below.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;&lt;script type=&quot;text/javascript&quot;&gt;
    $(document).ready(function () {
        $.ajax({
            type: &quot;POST&quot;,
            traditional: true,
            url: &#39;/Demo/DemoPartialResult&#39;,
            context: document.body,
            data: &quot;&quot;,
            success: function (result) {
                alert(result)
            },
            error: function (xhr) {
                //debugger;
                console.log(xhr.responseText);
            }
        });

    });
&lt;/script&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
Now, If you are trying to access that page then you can identify the error in Console window of the browser is as follows.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1twWFIK-Doe2VjWNxWeLFAHBep1M8TeDNhU22An_sAIGHI7zOFtwB7VDPEV-S1HkotB3SJoltbuBtp4S_8POytkZrgW6rOTJJwEuss24NykOthenzdHYTJJQy4O5ZexQ7v-tExuA3fTY/s1600/03-Partial-view-direct-access-ajax.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh1twWFIK-Doe2VjWNxWeLFAHBep1M8TeDNhU22An_sAIGHI7zOFtwB7VDPEV-S1HkotB3SJoltbuBtp4S_8POytkZrgW6rOTJJwEuss24NykOthenzdHYTJJQy4O5ZexQ7v-tExuA3fTY/s1600/03-Partial-view-direct-access-ajax.png&quot; height=&quot;118&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;h3&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;Conclusion&lt;/span&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;
I hope you got idea how to prevent Partial view Results directly accessing from URL or ajax calls in MVC. Please provide you valuable suggestions and comments if any.&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/3452880582109146117/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2014/09/prevent-partial-view-to-access-directly-in-mvc.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/3452880582109146117'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/3452880582109146117'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2014/09/prevent-partial-view-to-access-directly-in-mvc.html' title='Prevent Partial view to access directly in MVC'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/AVvXsEgYKwRZlXH9LeHNh8C9VqLuztHVVMB8SG7__k3u9uI-a8RFm5LLDAciskY7KL_ZIz6kfW_8TXBjtUZfVGgVxUvoWLGWfk7t3WoSk7nnkPIFs4Cro8yL_qSPYQvlsS0cbGvrs0fdC58Euz0/s72-c/01-Partial-view-display.png" height="72" width="72"/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-7335692346118436582</id><published>2014-09-16T15:14:00.001+05:30</published><updated>2014-09-16T15:15:54.289+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio"/><category scheme="http://www.blogger.com/atom/ns#" term="Visual Studio 2013"/><title type='text'>Visual Studio Key Notes</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;h3&gt;
            &lt;span style=&quot;color: #b45f06;&quot;&gt;About:&lt;/span&gt;
        &lt;/h3&gt;
&lt;br /&gt;
The Visual studio editor is vast and provides a ton of features. As you are working with visual studio editor, you should know the few features for those helps you a lot to improve the productivity while developing a code.&lt;br /&gt;
&lt;br /&gt;
So, In this post I am going to share with you about some of visual studio key points.&lt;/div&gt;
&lt;ol style=&quot;text-align: justify;&quot;&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Features&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Extensions&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Web Essentials&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; code snippets&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Help&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Quick Launch&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Refactoring&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
If you follow the above set of key points in visual studio along with some other, then while writing a code in visual studio is just like a &lt;b&gt;“Communication or discussion between you and visual studio”&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
            &lt;span style=&quot;color: #b45f06;&quot;&gt;Features:&amp;nbsp;&amp;nbsp;&lt;/span&gt;&amp;nbsp;
        &lt;/h3&gt;
&lt;/div&gt;
&lt;ol style=&quot;text-align: justify;&quot;&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Multiple Browsers set as Default&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Show code Preview tool tip&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Peek Definition&lt;/li&gt;
&lt;/ol&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/AVvXsEh2Ul4iNDBWh8YydUirskeJjj0UPAVXp2joTGwz3EP8WR-y6RyO92RLsp5eSd5ASRyB7mTeq7kUbw9SnZg5B6p0-MBPpcAw1kQFeZ40DkPrnZB2I37vx27HPBBTDdaYPp7hy5J4yrnclPQ/s1600/02-browser-with-popup.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;&lt;/a&gt;
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;h4&gt;
            &lt;span style=&quot;color: #b45f06;&quot;&gt;&amp;nbsp;&lt;/span&gt;
        &lt;/h4&gt;
&lt;h4&gt;
            &lt;span style=&quot;color: #b45f06;&quot;&gt;Multiple Browsers set as Default:&lt;/span&gt;
        &lt;/h4&gt;
&lt;br /&gt;
This feature is really very helpful when you get a chance to work on application, it should support various browsers.Normally, what you should do is run an application in one browser and then copy the same url to another browser to check the browser dependency or UI perspective or some other ways.&lt;br /&gt;
&lt;br /&gt;
But, In Visual studio also provides an option to set “Multiple Browsers” set as default. So you can run the application from visual studio it would open in all browsers. So, The setting should be setup by the following way.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYSBzENFbOK_9RO-LUv7H3K5ao4NfHlBQPFK5gGAqouE-TNSr4i9KeFfH896uUetTZO4qyMw_icFnLCNA7VotMUYn0PyUNauX_g-IqOmXWzdtmmDtRrFqUS_Ush9euP2OuhyJJwV6I0hQ/s1600/01-browser-with.png&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYSBzENFbOK_9RO-LUv7H3K5ao4NfHlBQPFK5gGAqouE-TNSr4i9KeFfH896uUetTZO4qyMw_icFnLCNA7VotMUYn0PyUNauX_g-IqOmXWzdtmmDtRrFqUS_Ush9euP2OuhyJJwV6I0hQ/s1600/01-browser-with.png&quot; height=&quot;302&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
As, per the browser the default browser is “Google Chrome”. Click on Browse with button then the screen should display as below.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Ul4iNDBWh8YydUirskeJjj0UPAVXp2joTGwz3EP8WR-y6RyO92RLsp5eSd5ASRyB7mTeq7kUbw9SnZg5B6p0-MBPpcAw1kQFeZ40DkPrnZB2I37vx27HPBBTDdaYPp7hy5J4yrnclPQ/s1600/02-browser-with-popup.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2Ul4iNDBWh8YydUirskeJjj0UPAVXp2joTGwz3EP8WR-y6RyO92RLsp5eSd5ASRyB7mTeq7kUbw9SnZg5B6p0-MBPpcAw1kQFeZ40DkPrnZB2I37vx27HPBBTDdaYPp7hy5J4yrnclPQ/s1600/02-browser-with-popup.png&quot; height=&quot;614&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
    &lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&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/AVvXsEgYhIOpL2Sd1NKYxbWzN4723Hw6uoKMfOCKgR7Qrljd21zQoak0XP6eU0IPnS-MdVJDZNg4qBnlh2kt8oR7yIQl0shY-RJnrb8XMTZ-PZ_-Xaa9LjNE7oqT68hOrxhcUiO33glzlBv4gCc/s1600/03-multiple-browser-select.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;&lt;/a&gt;
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
Now, Press the Ctrl button and click on “Firefox” then you are able to select two browser types (Just like select multiple list items from list box) and then hit on “Set as Default” button then the resultant screen would display is as follows.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYhIOpL2Sd1NKYxbWzN4723Hw6uoKMfOCKgR7Qrljd21zQoak0XP6eU0IPnS-MdVJDZNg4qBnlh2kt8oR7yIQl0shY-RJnrb8XMTZ-PZ_-Xaa9LjNE7oqT68hOrxhcUiO33glzlBv4gCc/s1600/03-multiple-browser-select.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgYhIOpL2Sd1NKYxbWzN4723Hw6uoKMfOCKgR7Qrljd21zQoak0XP6eU0IPnS-MdVJDZNg4qBnlh2kt8oR7yIQl0shY-RJnrb8XMTZ-PZ_-Xaa9LjNE7oqT68hOrxhcUiO33glzlBv4gCc/s1600/03-multiple-browser-select.png&quot; height=&quot;614&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Then close the window and hit a “ Ctrl + F5” button to run the application in two browsers (Google Chrome, Firefox) at a time.
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEgMKYYv6ntB_VQvQMHXATFextKJ29ffNqG2aRuh0I6oT9E9KF2MdpTnNFWTWNbtrp4dL3V5QujPcXv370eadFWpJkXbulUyiLHBnbOUDIsh7ACLV2OGD5UoA-g5x42ejbudlj0k0gHSUeA/s1600/04-multiple-browser-ouput.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgMKYYv6ntB_VQvQMHXATFextKJ29ffNqG2aRuh0I6oT9E9KF2MdpTnNFWTWNbtrp4dL3V5QujPcXv370eadFWpJkXbulUyiLHBnbOUDIsh7ACLV2OGD5UoA-g5x42ejbudlj0k0gHSUeA/s1600/04-multiple-browser-ouput.png&quot; height=&quot;358&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Note: &lt;/b&gt;The debugging feature (hit F5) is allow only for single application only. This multiple browser feature would be useful especially to test the GUI display for various browsers.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
            &lt;span style=&quot;color: #b45f06;&quot;&gt;Show Code preview tool tip:&lt;/span&gt;
        &lt;/h4&gt;
&lt;br /&gt;
This feature will be useful when code file contains hundreds of lines, In out of that you are going to search for particular block / piece of code.&lt;br /&gt;
&lt;br /&gt;
So, Normally to achieve the aforesaid requirement, you can use find or method name search for that few key strokes are required,&lt;br /&gt;
&lt;br /&gt;
Instead of that, while just moving the mouse to the vertical scroll bar location as it opens a small glance popup it would show the piece of code and just by clicking on that it would navigates to that particular code location is good right!!!..
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEjeVO1nsZ4Sp5waeBnDCcM8tD4orIktoxH7hgLEdOxUL6YX7rI2hulZEuTkoBHdobbTuBZQMlAV1mMUJFxbMha5MNDhlh4V91zjOdxUtWYifa1jKeyhoF6IZ4Uw9qtAnahJQl0-6YqEPVY/s1600/05-scroll-preview-popup.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjeVO1nsZ4Sp5waeBnDCcM8tD4orIktoxH7hgLEdOxUL6YX7rI2hulZEuTkoBHdobbTuBZQMlAV1mMUJFxbMha5MNDhlh4V91zjOdxUtWYifa1jKeyhoF6IZ4Uw9qtAnahJQl0-6YqEPVY/s1600/05-scroll-preview-popup.png&quot; height=&quot;346&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
Now, you can learn how can you setup this feature in visual studio 2013.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Steps:&lt;/b&gt;
    &lt;/div&gt;
&lt;ol style=&quot;text-align: justify;&quot;&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Tools&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Go to Options&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Expand Text Editor&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Expand C#&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Select Scroll Bars&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Go to the Behavior panel&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Select the “Use map mode for vertical scroll bar”&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
The resultant window screen looks like as follows.
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEjpatwy1tiQgGqRJ0zHRPxvZq8nqhxJpZcNY1QSLnX8DMeH9zXJPpoVmBN0YY2hUPd_4OvQaV4GY7b7p7aehBU3fDVRi7BxK3Qt7bGLqHf9OS6CsLSmYC-T1JY-bKhQ_oB1DV_9n58Z-Ks/s1600/06-scroll-preview-tooltip-enable-process.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpatwy1tiQgGqRJ0zHRPxvZq8nqhxJpZcNY1QSLnX8DMeH9zXJPpoVmBN0YY2hUPd_4OvQaV4GY7b7p7aehBU3fDVRi7BxK3Qt7bGLqHf9OS6CsLSmYC-T1JY-bKhQ_oB1DV_9n58Z-Ks/s1600/06-scroll-preview-tooltip-enable-process.png&quot; height=&quot;372&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: I hope this feature will be helpful when you are working on big screen like extended monitor it would be useful, for normal small laptop screens you can go with existing vertical bar only.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
            &lt;span style=&quot;color: #b45f06;&quot;&gt;Peek Definition:&lt;/span&gt;
        &lt;/h4&gt;
&lt;br /&gt;
As a coding practice and better maintainability will follow code ayers or design patterns. In such a scenario, some of the methods will be inherited from the other classes.&lt;br /&gt;
&lt;br /&gt;
So, In that cases if you want to check the method details with out moving to that particular this Peek definition helps you.&lt;br /&gt;
&lt;br /&gt;
You, just need to place a cursor on any of the method and click on “Alt + F12” it opens small popup contains the method details.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
            &lt;span style=&quot;color: #b45f06;&quot;&gt;Extensions:&lt;/span&gt;
        &lt;/h3&gt;
&lt;br /&gt;
Visual studio supports the extensions which helps to achieve the required things those are not included or in a better way by creating visual studio extensions in (.vsix) file format.&lt;br /&gt;
&lt;br /&gt;
You can install/manage the visual studio extensions from Visual studio itself,By Navigating to Tools and Extensions and Updates.. or else you can directly install extensions from Visual Studio gallery. Some of the extensions are as follows.&lt;/div&gt;
&lt;ol style=&quot;text-align: justify;&quot;&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Spell checker&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Go To Definition&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Productivity Power Tools 2013&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;h4&gt;
            &lt;span style=&quot;color: #b45f06;&quot;&gt;Spell checker:&lt;/span&gt;
        &lt;/h4&gt;
&lt;br /&gt;
Spell checker is one of the great tool as this would be very useful to get rid of some silly/typo mistakes while placing some comments in code level. As placing comments at code level is one of the best thing in code practices.&lt;br /&gt;
&lt;br /&gt;
You can download the tool from this link &lt;a href=&quot;http://visualstudiogallery.msdn.microsoft.com/7c8341f1-ebac-40c8-92c2-476db8d523ce&quot; target=&quot;_blank&quot;&gt;Spell Checker&lt;/a&gt; or else you can directly install from visual studio as well.&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
            &lt;span style=&quot;color: #b45f06;&quot;&gt;Go To Definition:&lt;/span&gt;
        &lt;/h4&gt;
&lt;br /&gt;
Visual studio provides so many features like (F12) to go to the definition of code and (Alt+ F12) peek definition to view the code in current location window only with small popup also. Even though this extension provides in a other way to view the code.&lt;br /&gt;
&lt;br /&gt;
If you press and hold the Ctrl key and just mouse over any definition then it turns into a hyper link, By clicking on that link it would navigate to that definition of the code block.&lt;br /&gt;
&lt;br /&gt;
You can download that one from this link &lt;a href=&quot;http://visualstudiogallery.msdn.microsoft.com/4b286b9c-4dd5-416b-b143-e31d36dc622b&quot; target=&quot;_blank&quot;&gt;Go To Definition&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h4&gt;
            &lt;span style=&quot;color: #b45f06;&quot;&gt;Productivity Power Tools 2013:&lt;/span&gt;
        &lt;/h4&gt;
&lt;br /&gt;
The name itself indicates that this tool is very helpful to improve the productivity while writing the code in visual studio 2013. you can call this one as a package instead of extension as this comes with lot of options with customization settings even you can disable / change the setting as you desired.&lt;br /&gt;
&lt;br /&gt;
you can check out description and get the details and download the extension from this link &lt;a href=&quot;http://visualstudiogallery.msdn.microsoft.com/dbcb8670-889e-4a54-a226-a48a15e4cace&quot; target=&quot;_blank&quot;&gt;Power Tools&lt;/a&gt;.
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Installed Extensions in a visual studio having a features like to disable or uninstall the extensions as well.&lt;br /&gt;
&lt;br /&gt;
The Extensions are managed from Visual studio by following this steps.&lt;/div&gt;
&lt;ol style=&quot;text-align: justify;&quot;&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Tools&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Go To Extensions and Updates&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; select Installed option on left most corner from the opened pop up&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; It would show the list of installed extensions&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Now, You can disable or Uninstall the required extension.&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;h3&gt;
            &lt;span style=&quot;color: #b45f06;&quot;&gt;Web Essentials:&lt;/span&gt;
        &lt;/h3&gt;
&lt;br /&gt;
Web essentials is also one of the best one which will provide great flexibility while writing a code in visual studio editor.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;LESS:&lt;/b&gt; Less css is kind of dynamic stylesheet language which is very helpful while designing css for any templates or forms. you can get more details from my &lt;a href=&quot;http://ramchandr.blogspot.com/2014/09/less-css-in-net_7.html&quot; target=&quot;_blank&quot;&gt;blog&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;ZenCoding:&lt;/b&gt; ZenCoding is the one of the greatest feature (at least I feel) in the Web essentials. It helps you a lot to write HTML code in fastest way even visual studio 2013 provides itself a lot of features like (automatically closes (or modify/update) the tag when you write start tag and etc). You can get additional details from my &lt;a href=&quot;http://ramchandr.blogspot.com/2014/09/zencoding-lorem-pixel-generator-vs-net-2013.html&quot; target=&quot;_blank&quot;&gt;blog&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
It also contains a great list of features like TypeScript and etc. you can get more idea about web essentials by checking this link &lt;a href=&quot;http://vswebessentials.com/&quot; target=&quot;_blank&quot;&gt;Web Essentials&lt;/a&gt;. you can download the web essentials separately based on&amp;nbsp; visual studio version, For Visual studio 2013 the&amp;nbsp; link for visual studio gallery&amp;nbsp; and official site link &lt;a href=&quot;http://visualstudiogallery.msdn.microsoft.com/56633663-6799-41d7-9df7-0f2a504ca361&quot; target=&quot;_blank&quot;&gt;web essentials&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
            &lt;span style=&quot;color: #b45f06;&quot;&gt;Code Snippets:&lt;/span&gt;
        &lt;/h3&gt;
&lt;br /&gt;
As a developer, Everyone have an idea of some basic C# code blocks like (if.. else, for, foreach, switch,while, creating constructor etc etc..)&lt;br /&gt;
&lt;br /&gt;
But, Just think about it while choosing any one of the aforesaid code block, and just have a count of how many key strokes are used to write that block.&lt;br /&gt;
&lt;br /&gt;
For Example, for writing single if condition like the below it would take minimum of 6 to 7 even visual studio provides automatic feature of closing of braces.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;if()
{

}
&lt;/pre&gt;
&lt;br /&gt;
But, If you have an idea of code snippets, you can achieve that one in only 4 key strokes. By typing &lt;b&gt;“if”&lt;/b&gt; and then press &lt;b&gt;“TAB”&lt;/b&gt; then visual studio will create if block for you.&lt;br /&gt;
&lt;br /&gt;
The other example is, If you are having a class named as “Customer.cs” then you are going to create constructor for that class. By using code snippet you can just type &lt;b&gt;“ctor”&lt;/b&gt; and then &lt;b&gt;hit TAB&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
Thats it!!!!... The constructor is ready with the code.&lt;br /&gt;
&lt;br /&gt;
In the similar way for writing try..catch block, just write &lt;b&gt;“try”&lt;/b&gt; and then hit TAB.&lt;br /&gt;
&lt;br /&gt;
In the above scenario,The difficult thing is only you just need to have an idea on “ctor” will creates code snippet for constructor block.&lt;br /&gt;
&lt;br /&gt;
Now, The question is how should you know these kind of things.&lt;br /&gt;
&lt;br /&gt;
It is just simple, In any of the code block (c#) or even in .cshtml page block as well, Right Click and then click on “Insert Snippet” then the resultant screen would display like the below.
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEhsmYar4jnRhKnML6uQhuxDB0vCPcgOi1jryQlky52R7zd77KgkzOBYrQUcuL_zP4NsFDVR5ogGhtfwQHRnwcDQc4y2Ezn1aMAmH-hX8NodTEHT87JEXcdFPVaoypRDm5HP1WiyzwPWx8c/s1600/07-select-code-snippet.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsmYar4jnRhKnML6uQhuxDB0vCPcgOi1jryQlky52R7zd77KgkzOBYrQUcuL_zP4NsFDVR5ogGhtfwQHRnwcDQc4y2Ezn1aMAmH-hX8NodTEHT87JEXcdFPVaoypRDm5HP1WiyzwPWx8c/s1600/07-select-code-snippet.png&quot; height=&quot;441&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
you can select or review the code snippet names by checking in “Visual C#” or “ASP.NET MVC4” or others and then habituate in the day to day coding style then definitely you could do better code in a productive manner.&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
            &lt;span style=&quot;color: #b45f06;&quot;&gt;Help:&lt;/span&gt;
        &lt;/h3&gt;
&lt;br /&gt;
As a developer, you can learn the things in a day to day code by exploring the things. In this manner, Help is needed to learn or understand the things, The same scenario, you could relate with visual studio editor code implementation.&lt;br /&gt;
&lt;br /&gt;
For Example, if you want to get the details about a C# keyword “string”. Instead of searching in google or somewhere else , place a cursor on that keyword and hit “F1”.&lt;br /&gt;
&lt;br /&gt;
The specialty of this search is sensitive framework dependent. Like , If you hit “F1” from the .Net Framework 4.5 application then the msdn help browser will open the result for .Net Framewoek 4.5 only.&lt;br /&gt;
&lt;br /&gt;
The Visual studio provides offline base search also by changing the help preferences from visual studio.
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp;
    &lt;/div&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/AVvXsEiOy1zI3PQjg5PnIyD3242IDXAPYKBgP9FhAyUwhGwkF4RE-pxTNHl1ViPFZpjRqLrxNVeCJ2Kgj7G41cvhQ-H8rBpRUKT0AysPCzOtUVEMfqJW46nK8gcGdOoAZfH5n-yA2-upgBN6JC0/s1600/08-about-help.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiOy1zI3PQjg5PnIyD3242IDXAPYKBgP9FhAyUwhGwkF4RE-pxTNHl1ViPFZpjRqLrxNVeCJ2Kgj7G41cvhQ-H8rBpRUKT0AysPCzOtUVEMfqJW46nK8gcGdOoAZfH5n-yA2-upgBN6JC0/s1600/08-about-help.png&quot; height=&quot;348&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp;
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
            &lt;span style=&quot;color: #b45f06;&quot;&gt;Quick Launch:&lt;/span&gt;
        &lt;/h3&gt;
&lt;br /&gt;
This option is exists generally at right most corner of visual studio. Before discussing with you about this feature, just a few simple questions.&lt;/div&gt;
&lt;ol style=&quot;text-align: justify;&quot;&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Have you ever searched in VS menus to for BreakPoints bar to get list of&amp;nbsp; BreakPoints?&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Have you ever searched in VS menus for Immediate window?&lt;/li&gt;
&lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Have you ever searched in a VS for Solution explorer if its not in right side of editor?&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
The Quick Launch will helps you a lot to avoid these kind of simple and even some complicated setting with out remembering all those as visual studio is a vast and it contains tons of features.&lt;br /&gt;
&lt;br /&gt;
Bu just typing, some related words in quick launch it would gives a result by clicking on that it would opens the required ones.&amp;nbsp;
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Few examples are mentioned below.
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&amp;nbsp;
    &lt;/div&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/AVvXsEg1BXuVh8cmsAO6UukbDjkO2CP_069WXlQ8K80WOdGMBs_IU1g8B5xf8YcgT6AlRgeiwKimGNUIf80E24PHZdhxphMrG2y5fd1M8SvOX9aTuyf8atv0O5uKnJ8Nn9kv6ztukCJ7Ck6HgF0/s1600/09-quick-launch-01.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg1BXuVh8cmsAO6UukbDjkO2CP_069WXlQ8K80WOdGMBs_IU1g8B5xf8YcgT6AlRgeiwKimGNUIf80E24PHZdhxphMrG2y5fd1M8SvOX9aTuyf8atv0O5uKnJ8Nn9kv6ztukCJ7Ck6HgF0/s1600/09-quick-launch-01.png&quot; height=&quot;234&quot; width=&quot;600&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/AVvXsEi0b3Uh-Sc65FyqEfFtm8DZopLf2bbNErTFPQjXAALXVuJ54nGsQbrjajB96DF8M_AkbrDSpIP0dekv6g1_12ObKn8tH6-CSN32vADzjhG7anQLuYizNwWy7u-a9Cu80N4s01iYSl9S_Yk/s1600/10-quick-launch-02.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi0b3Uh-Sc65FyqEfFtm8DZopLf2bbNErTFPQjXAALXVuJ54nGsQbrjajB96DF8M_AkbrDSpIP0dekv6g1_12ObKn8tH6-CSN32vADzjhG7anQLuYizNwWy7u-a9Cu80N4s01iYSl9S_Yk/s1600/10-quick-launch-02.png&quot; height=&quot;402&quot; width=&quot;600&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/AVvXsEglkiaO2I2QgM4ADUVAWrFGgxhcMqElrOJerB7XFJDwwaVgtCzKec0VABf3J9_mV0k_OUslHJN0rCc4CI9AQSxWXmb0-jVFnyfylgimf_ytdzLDxuyGU7EJaCD5ActG_To1y2A9tul3A1E/s1600/11-quick-launch-03.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglkiaO2I2QgM4ADUVAWrFGgxhcMqElrOJerB7XFJDwwaVgtCzKec0VABf3J9_mV0k_OUslHJN0rCc4CI9AQSxWXmb0-jVFnyfylgimf_ytdzLDxuyGU7EJaCD5ActG_To1y2A9tul3A1E/s1600/11-quick-launch-03.png&quot; height=&quot;328&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;h3&gt;
            &lt;span style=&quot;color: #b45f06;&quot;&gt;Refactoring:&lt;/span&gt;
        &lt;/h3&gt;
&lt;br /&gt;
Code Refactoring is also having its own importance while writing a code. Suppose if you have written some block of code as a initial code development. After certain moment, you have noticed that the same block of code will be required at some other location.&lt;br /&gt;
&lt;br /&gt;
Then, Usually what you will do, Remove that block of code, create a method separately with that code then call that method in the required places where as desired.&lt;br /&gt;
&lt;br /&gt;
The whole process will be managed by Visual studio Refactoring option.&lt;br /&gt;
&lt;br /&gt;
You, Just need to do is only select the required code block, Right click and select the Refactoring option.
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&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/AVvXsEjq9PJODrYhAQfT55waB_tBqhYINkW9FJgjFgY1VCFxkf5B5ccCFUsovEarw7i60Mq6aDdLouQxh6jsNFcEsYJLmU7XSm1ouROETeDsgO5O169v8uqbVlI5IBVVsF6-GK0u9S0hLPeyYU4/s1600/12-refactor-step1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjq9PJODrYhAQfT55waB_tBqhYINkW9FJgjFgY1VCFxkf5B5ccCFUsovEarw7i60Mq6aDdLouQxh6jsNFcEsYJLmU7XSm1ouROETeDsgO5O169v8uqbVlI5IBVVsF6-GK0u9S0hLPeyYU4/s1600/12-refactor-step1.png&quot; height=&quot;146&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
    &lt;/div&gt;
&lt;br /&gt;
And then just click on &quot;Extract Method&quot;&amp;nbsp; then it opens a popup like the below.&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/AVvXsEg05GhIdWcfRN5mAM6Ujrr1C79y92F3x8myUs76L8eue1rUnpEuaGCSIAVENC8OyUYv6zRJwj9iFgfhF1rG5OWexxhC9WnuFB_kO30DrdxMRRwl_QmKvrr3zQhTMkSdyaVJjSC37ylQ618/s1600/13-refactor-step2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg05GhIdWcfRN5mAM6Ujrr1C79y92F3x8myUs76L8eue1rUnpEuaGCSIAVENC8OyUYv6zRJwj9iFgfhF1rG5OWexxhC9WnuFB_kO30DrdxMRRwl_QmKvrr3zQhTMkSdyaVJjSC37ylQ618/s1600/13-refactor-step2.png&quot; height=&quot;256&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
    &lt;/div&gt;
&lt;br /&gt;
Now, By Clicking on &quot;Ok&quot; button&amp;nbsp; then the code result will display is as follows.&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/AVvXsEgimp1lgrh_9on1QJVgZNdTDfwV0gDXE_Fez7Bj6PRRtLHQr5kac2gz-zs7OV0xpq3qqFuwybUmpq8H6RqNQHIEuitGdANwFzuVphUhF8ZQCSOHY-8RGSyNPL86KKaJ1Tx1lkpz-qCRGck/s1600/14-refactor-step3.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgimp1lgrh_9on1QJVgZNdTDfwV0gDXE_Fez7Bj6PRRtLHQr5kac2gz-zs7OV0xpq3qqFuwybUmpq8H6RqNQHIEuitGdANwFzuVphUhF8ZQCSOHY-8RGSyNPL86KKaJ1Tx1lkpz-qCRGck/s1600/14-refactor-step3.png&quot; height=&quot;354&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
    &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
            &lt;span style=&quot;color: #b45f06;&quot;&gt;Conclusion:&lt;/span&gt;
        &lt;/h3&gt;
&lt;br /&gt;
I hope the provided key notes on visual studio will help you to write code in a smart way with less pain.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/7335692346118436582/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2014/09/visual-studio-key-notes-and-features.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/7335692346118436582'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/7335692346118436582'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2014/09/visual-studio-key-notes-and-features.html' title='Visual Studio Key Notes'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/AVvXsEgYSBzENFbOK_9RO-LUv7H3K5ao4NfHlBQPFK5gGAqouE-TNSr4i9KeFfH896uUetTZO4qyMw_icFnLCNA7VotMUYn0PyUNauX_g-IqOmXWzdtmmDtRrFqUS_Ush9euP2OuhyJJwV6I0hQ/s72-c/01-browser-with.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-5078866103907718098</id><published>2014-09-15T09:53:00.000+05:30</published><updated>2014-09-15T10:38:07.865+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ActionResult"/><category scheme="http://www.blogger.com/atom/ns#" term="MVC"/><category scheme="http://www.blogger.com/atom/ns#" term="MVC 5.0"/><category scheme="http://www.blogger.com/atom/ns#" term="PartialViewResult"/><title type='text'>Partial View Result Return Type in MVC 5 with sample Web application</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: left;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;About:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;PartialView is the one of&amp;nbsp; the ActionResult type in MVC. This is also inherited from the ViewresultBase clas.&amp;nbsp; You can use Partial View is kind of user control in MVC. &lt;br /&gt;&lt;br /&gt;So, This PartialView is mostly used for to reduce the repetitive code and also for easy code maintainability.&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;/div&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
        &lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;How Can you Call/Display Partial View:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;/h2&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: left;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;you can call or display partial view with in the view mainly in four types with the use of html helper methods.&lt;br /&gt;&lt;br /&gt;Those are&lt;br /&gt;&lt;br /&gt;1. Html.Partial&lt;br /&gt;2. Html.RenderPartial&lt;br /&gt;3. Html.Action&lt;br /&gt;4. Html.RenderAction&lt;br /&gt;&lt;br /&gt;I can discuss more about these types in a later post. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
        &lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;Example:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;/h3&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
        
    &lt;/h4&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: left;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;A customer having the details of customer Id, Customer Name and address like Present and Permanent address details. &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
            &lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;Key Points to Cover:&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/h3&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Display the customer details using partial view&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Edit, update the details using partial view&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Create the customer details by using partial view&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Delete the customer details by using partial view&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;How to use Partial view in a view more than once (As I discussed it is kind of user control in MVC)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Strongly typed Partial Views &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Note:&amp;nbsp; This demo is being prepared with Visual Studio 2013 and MVC 5.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;you can download the sample project source from the link &lt;a href=&quot;https://drive.google.com/file/d/0B895m2cC0XzeWXB6aUthcUpONVE/edit?usp=sharing&quot; target=&quot;_blank&quot;&gt;Download Project&lt;/a&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;Step 1:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I am going to create new project in Visual Studio 2013 application.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Add a New project from the visual studion, then the displayed screen is as follows.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: left;&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxefF888uv1-5eAk10Zo-LNvSbzxrtoKrPvqP7xWhnJPpsQPFp3m0gvYvEZ0x-M9xBOv7EyOT8VHaU86s3bnV59wzX8QNz218J7ueZ1nPJQJVMQgxM2tmlWniihyu5OLsrJnRPaGf0TBo/s1600/01-start-project-2013.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgxefF888uv1-5eAk10Zo-LNvSbzxrtoKrPvqP7xWhnJPpsQPFp3m0gvYvEZ0x-M9xBOv7EyOT8VHaU86s3bnV59wzX8QNz218J7ueZ1nPJQJVMQgxM2tmlWniihyu5OLsrJnRPaGf0TBo/s1600/01-start-project-2013.png&quot; height=&quot;441&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
        &lt;/div&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: left;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;As, you can see in Visual Studio 2013, you are having only one type of Web application, But if you are selected in VS 2012 template it looks like below.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&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/AVvXsEga3AwNKib2B8Fv4x-VUM6pyqhGm1M5a7mv8Hi41Wc53i5X6pZWor9Z2FU8ijcXt2tCYJOeBXV8HMebWx5-iiG1f7rh69RkXIfmgofe9CPnSg5kcFYpep8h9ETS3x-s1nH1GP1IPt4lERQ/s1600/02-start-project-2012.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEga3AwNKib2B8Fv4x-VUM6pyqhGm1M5a7mv8Hi41Wc53i5X6pZWor9Z2FU8ijcXt2tCYJOeBXV8HMebWx5-iiG1f7rh69RkXIfmgofe9CPnSg5kcFYpep8h9ETS3x-s1nH1GP1IPt4lERQ/s1600/02-start-project-2012.png&quot; height=&quot;444&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
        &lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;In this example, I am using Visual Studio 2013 with MVC5.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;Step 2:&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;you can type the Name as “MvcPartialViewResultDemo” and then click on Ok button then the resultant screen displayed as below.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&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/AVvXsEgLh6Sd97aXpcawqDjOHf7kyg2UcpCvlbBApNYvyE7g9ax0Oev3al-K6aoTjpztKCLrG4lxk_RYor7FQNIBOIqQcYaqegjM2d1HbyV4Dg6_i8FNrL9rPKkEaM4Z5X5yeag9S-PA7tOmM8w/s1600/03-mvc-with-unit-test-project-selection.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLh6Sd97aXpcawqDjOHf7kyg2UcpCvlbBApNYvyE7g9ax0Oev3al-K6aoTjpztKCLrG4lxk_RYor7FQNIBOIqQcYaqegjM2d1HbyV4Dg6_i8FNrL9rPKkEaM4Z5X5yeag9S-PA7tOmM8w/s1600/03-mvc-with-unit-test-project-selection.png&quot; height=&quot;486&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
        &lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Here, you can select the project template as “MVC” and also select the “Add unit tests”&amp;nbsp; at the left most corner of the the template then the Test project name displayed as “MvcPartialViewResultDemo.Tests”.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Its always better practice to select the Unit test project in MVC as it supports TDD (Test Data Driven) approach.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;Step 3:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Click on Ok button, then it would create beautiful MVC application with addition of so many features like Login, Register, sample Layout with Responsive design approach (Bootstrap), claim based authentication template (Like login through gmail, facebook etc).&amp;nbsp; You can simply say that this is the power of visual studio. The displayed project home screen is as follows.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&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/AVvXsEjYZb-XF3_kDzc12ZOwKK6jhTGxyxSD5qP3I91yJbd2JdgH0l12R204jOVi0UfQeqvu4Dm659BRpDE-_xiMZ8Opf-dFdVPRcEy_NjbwUKvRzL5te2GNb8oYBmvHUjWeRsBdw8g9pb4bcnI/s1600/04-project-start.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYZb-XF3_kDzc12ZOwKK6jhTGxyxSD5qP3I91yJbd2JdgH0l12R204jOVi0UfQeqvu4Dm659BRpDE-_xiMZ8Opf-dFdVPRcEy_NjbwUKvRzL5te2GNb8oYBmvHUjWeRsBdw8g9pb4bcnI/s1600/04-project-start.png&quot; height=&quot;372&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
        &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Now, Just click on F5 button, to see the sample MVC application till now what you have created.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&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/AVvXsEgiDfCBx3mUHZtYmwnLKUFgISAiUlMZSg8VWIsk0bnsbAoihhcTgTz5eEFITXalKede0Jqm5UT4G3F_WWttSVafNyqrJJxJXRTWW7lFHmW0EoTP0zhJT23sG4Tn0VeJH1cMpz2s9s7jOmA/s1600/05-initial-project-output.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgiDfCBx3mUHZtYmwnLKUFgISAiUlMZSg8VWIsk0bnsbAoihhcTgTz5eEFITXalKede0Jqm5UT4G3F_WWttSVafNyqrJJxJXRTWW7lFHmW0EoTP0zhJT23sG4Tn0VeJH1cMpz2s9s7jOmA/s1600/05-initial-project-output.png&quot; height=&quot;380&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
        &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;you, can just click on “Restore Down” button or just reduce the browser width then you can identify the resultant responsive design as follows.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&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/AVvXsEgSvoavr0ihFKFK_imhzz8eFtu1OEm9oQAZjkzVsAyuzxoDJkVtr_xQusb9eiTtymiefZrPOWnz-2yX5rppKd-3DxqMJe3w3xgcD88qwkWAnZN9g0poF1J8W5ckgu7M_Q0pPFTReXgKops/s1600/06-initial-project-responsive-output.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSvoavr0ihFKFK_imhzz8eFtu1OEm9oQAZjkzVsAyuzxoDJkVtr_xQusb9eiTtymiefZrPOWnz-2yX5rppKd-3DxqMJe3w3xgcD88qwkWAnZN9g0poF1J8W5ckgu7M_Q0pPFTReXgKops/s1600/06-initial-project-responsive-output.png&quot; height=&quot;640&quot; width=&quot;490&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;So, Sample MVC web application is ready even with out writing single line of code.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;Step 4:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;The web application solution explorer looks like below.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&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/AVvXsEhnsbk9WuTUZlNVM6sdWuAgKwdqXZtTIjU64vYCcPQi754mZdqsxEW-Egm-jOobCJB36um0AWo-qpAX3dCVjVylvcMDDEaD5fqq1xsT5IRcO1FnPzi_8TSX0Yi7HYYFmWjdrpxx2NMxlJ8/s1600/07-mvc-solution-explorer.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhnsbk9WuTUZlNVM6sdWuAgKwdqXZtTIjU64vYCcPQi754mZdqsxEW-Egm-jOobCJB36um0AWo-qpAX3dCVjVylvcMDDEaD5fqq1xsT5IRcO1FnPzi_8TSX0Yi7HYYFmWjdrpxx2NMxlJ8/s1600/07-mvc-solution-explorer.png&quot; height=&quot;640&quot; width=&quot;286&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;The highlighted parts of solution explorer as Model, View and Controller, you mainly work on those following components in this example.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Now, you can add one class named as CustomerModel.cs in the Model folder by right click on Model folder then Add and choose the class.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&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/AVvXsEjm8vZNYF1MPth8Ut8ewQAdXfXOFVnNMxDYoslKB9E_GOVdMlIMp36MpUQwnfMv8lI5Ldi8dWU97hEOa4De7PpL0B8jynFlDhVv1VtLMQx163c3mmlaH_b1uURhmaAt_YvlcPKj7Gm4U24/s1600/08-modal-class-creation.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjm8vZNYF1MPth8Ut8ewQAdXfXOFVnNMxDYoslKB9E_GOVdMlIMp36MpUQwnfMv8lI5Ldi8dWU97hEOa4De7PpL0B8jynFlDhVv1VtLMQx163c3mmlaH_b1uURhmaAt_YvlcPKj7Gm4U24/s1600/08-modal-class-creation.png&quot; height=&quot;374&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;By clicking on “class” the template looks like below.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&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/AVvXsEgOYqpbfGVKV8i_pFbgYrEWKlastQEBxlAdGDPS3BhxjruJ-Zb4j8NtonErMkbXu9x48K4JM1wdf2uER4KBVwRNPE_gaHXfOgSa7ZU47SvtWKuFSm88qCwOXkjhcfbh3KiYH8o098uBEJw/s1600/09-customer-model-class.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOYqpbfGVKV8i_pFbgYrEWKlastQEBxlAdGDPS3BhxjruJ-Zb4j8NtonErMkbXu9x48K4JM1wdf2uER4KBVwRNPE_gaHXfOgSa7ZU47SvtWKuFSm88qCwOXkjhcfbh3KiYH8o098uBEJw/s1600/09-customer-model-class.png&quot; height=&quot;442&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
        &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Click on “Add” button then the class will be created. Now, you can replace that class file code with the below code.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&gt;
&lt;/div&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MvcPartialViewResultDemo.Models
{
    public class CustomerModel
    {
        public int CustmerId { get; set; }
        public string CustomerName { get; set; }
        public CustomerAddress PermanantAddress { get; set; }
        public CustomerAddress PresentAddress { get; set; }
    }
    public class CustomerAddress
    {
        public string DoorNumber { get; set; }
        public string City { get; set; }
        public string State { get; set; }
        public string PinNumber { get; set; }
    }
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Now, The Customer Model is ready in your application.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;You can add a controller named as CustomerController.cs in the controller folder.&lt;br /&gt;Right click on&amp;nbsp; Controllers folder then Add and the controller&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&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/AVvXsEh_FjMzzX096ViyHfQ1fPWrA1QYZSUaK5M1Ra5DX9aJER7PgGYAoLNsUocxgXPUAK0zoYlQ2EerXDewNIYVRJadPJEkhwbNZYS9v39k_AqtsV9TLhdlfUhWN4we2bcFjMkZPs5rBYKY8eg/s1600/10-customer-controller.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_FjMzzX096ViyHfQ1fPWrA1QYZSUaK5M1Ra5DX9aJER7PgGYAoLNsUocxgXPUAK0zoYlQ2EerXDewNIYVRJadPJEkhwbNZYS9v39k_AqtsV9TLhdlfUhWN4we2bcFjMkZPs5rBYKY8eg/s1600/10-customer-controller.png&quot; height=&quot;470&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
        &lt;/div&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;Click on “Controller” then the screen looks like below.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&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/AVvXsEgE-rjpM3SaOhlwox_M10ova2-hwstgKIpaPoflH4K_JmoIvX_lRSAwOWvNjpXqPcg8nX8Onb1Xtn4hXYZLLp2Bb7QeaRJQrJxRD1P6Cgp_cjlqGGCboh1NczsyRSptdbXg8IEE-82l4vI/s1600/11-customer-controller-read-write.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgE-rjpM3SaOhlwox_M10ova2-hwstgKIpaPoflH4K_JmoIvX_lRSAwOWvNjpXqPcg8nX8Onb1Xtn4hXYZLLp2Bb7QeaRJQrJxRD1P6Cgp_cjlqGGCboh1NczsyRSptdbXg8IEE-82l4vI/s1600/11-customer-controller-read-write.png&quot; height=&quot;442&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
        &lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;This above template provides various types of controllers, In that you can choose the template named as “MVC 5 Controller with read/write actions” then click on “Add” button then another popup will appear its asks you about controller name. So, name it as “CustomerController” like the below.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&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/AVvXsEgLNtS_Jw326cmmik8-iAfCrClIwvrdp7P6ApLI8Cb7LwE3enJpPUa2zZ03esEoThrKyOMqvXmks-JQAzZpg5ABS4atxnMwpaS_hC4s5v00NdPTvhrwoc3YnewGezdT33xvlqEoxqcmK64/s1600/12-customer-controller-add.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLNtS_Jw326cmmik8-iAfCrClIwvrdp7P6ApLI8Cb7LwE3enJpPUa2zZ03esEoThrKyOMqvXmks-JQAzZpg5ABS4atxnMwpaS_hC4s5v00NdPTvhrwoc3YnewGezdT33xvlqEoxqcmK64/s1600/12-customer-controller-add.png&quot; height=&quot;136&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
        &lt;/div&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Now, Just click on “Add” button, It would create CustomerController.cs file.&lt;br /&gt;&lt;br /&gt;Are you bit surprised!!! while checking the code as it generates so much of code with all read/write actions. This is the power of template while creating a customer controller what you have chosen.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;Note:&lt;/b&gt;&lt;/span&gt; Even you can define your own level of changes in that controller template by defining custom CodeTemplates (T4 Templates) in your project folder as well.&lt;br /&gt;&lt;br /&gt;The CustomerController.cs&amp;nbsp; code file looks like below.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&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/AVvXsEjIeYZ1tu2tyErYM3FihOL3adEjuRKk1iKL4xmtror5pWXumXBcHARKtg-Gho-nouAn9QtS1ywvOHogF2S6eRLsL6qpQZ8VDNckYZYhyxzCrVfK0ya9orYGH3XnB-k9WGcbimXBsDg19Ek/s1600/13-customer-controller-initial-code.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIeYZ1tu2tyErYM3FihOL3adEjuRKk1iKL4xmtror5pWXumXBcHARKtg-Gho-nouAn9QtS1ywvOHogF2S6eRLsL6qpQZ8VDNckYZYhyxzCrVfK0ya9orYGH3XnB-k9WGcbimXBsDg19Ek/s1600/13-customer-controller-initial-code.png&quot; height=&quot;372&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
        &lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;Step 6: &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now, you are going to add a partial view which helps to display Address details of a customer. Partial Views can be added with in the parent controller or a shared folder. As a part of coding practice the partial view can be prefixed with “_”.&lt;br /&gt;&lt;br /&gt;Add a partial view by following the below steps&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Go to Solution Explorer&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Views folder&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Inside Views folder right click on Shared folder&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Click on Add and then View&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;The resultant screen looks like follows.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&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/AVvXsEjbyOuBWY-BJ5Rvc12694mNsASVghTbfqmnXXQx2XhrDYjCILm8YVFB1n4G1xLhBh2eVEJgx8rgBZehbTZlQeSkERusg8q4eXawej8M32Acvi7EFHofL1AF9dHZXkQY_8-uDp6SMp05VBA/s1600/17-add-customer-details-partial-view.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbyOuBWY-BJ5Rvc12694mNsASVghTbfqmnXXQx2XhrDYjCILm8YVFB1n4G1xLhBh2eVEJgx8rgBZehbTZlQeSkERusg8q4eXawej8M32Acvi7EFHofL1AF9dHZXkQY_8-uDp6SMp05VBA/s1600/17-add-customer-details-partial-view.png&quot; height=&quot;454&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Now, click on “View” it opens a popup and apply the changes as per below screen&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&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/AVvXsEjdaW4cTnz5I0R4eULlf5hyphenhyphen12dMsJDgFKlPqvd9J6469YCjDG7Jut6PiMRAc_Js00kd2iHzSETzgzzak_lyGvMlIOGS_76obMJGoT_gnNlaGPnZVbLk_vWkTZKjsY31uZ5VQnKdPaAPRdY/s1600/18-Partial-view-address-details.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdaW4cTnz5I0R4eULlf5hyphenhyphen12dMsJDgFKlPqvd9J6469YCjDG7Jut6PiMRAc_Js00kd2iHzSETzgzzak_lyGvMlIOGS_76obMJGoT_gnNlaGPnZVbLk_vWkTZKjsY31uZ5VQnKdPaAPRdY/s1600/18-Partial-view-address-details.png&quot; height=&quot;392&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
        &lt;/div&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;b&gt;Changes:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;View Name: _CustomerAddressDetails&lt;br /&gt;Template Name: List&lt;br /&gt;Model class: CustomerAddress&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;select the Create as a Partial view option and then click on “Add” button to creates the partial view. Now, Replace the “_CustomerAddressDetails.cshtml” code with the below code.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;/div&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;@model MvcPartialViewResultDemo.Models.CustomerAddress
&lt;div&gt;

&lt;dl class=&quot;dl-horizontal&quot;&gt;
&lt;dt&gt;
            @Html.DisplayNameFor(model =&amp;gt; model.DoorNumber)
        &lt;/dt&gt;
&lt;dd&gt;@Html.DisplayFor(model =&amp;gt; model.DoorNumber)
        &lt;/dd&gt;
&lt;dt&gt;
            @Html.DisplayNameFor(model =&amp;gt; model.City)
        &lt;/dt&gt;
&lt;dd&gt;@Html.DisplayFor(model =&amp;gt; model.City)
        &lt;/dd&gt;
&lt;dt&gt;
            @Html.DisplayNameFor(model =&amp;gt; model.State)
        &lt;/dt&gt;
&lt;dd&gt;@Html.DisplayFor(model =&amp;gt; model.State)
        &lt;/dd&gt;
&lt;dt&gt;
            @Html.DisplayNameFor(model =&amp;gt; model.PinNumber)
        &lt;/dt&gt;
&lt;dd&gt;@Html.DisplayFor(model =&amp;gt; model.PinNumber)
        &lt;/dd&gt;
    &lt;/dl&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;Step 7:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;You can add view to the controller action method named as Index to display the list of all customer details.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&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/AVvXsEguT7fncWiHzzkOeQ1FS09fxgc6eUUOnwiJVqHDi4NHAQfWoDJq4-L-p5Y6ziz6ptJU8G9aKDB8b5-GnmNmvin_-lBR1tm75FZDXefapi3Awg6dBhpbsZS6TqijepXz0L4XmmiXLCWJDrU/s1600/14-add-view-customer-details.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEguT7fncWiHzzkOeQ1FS09fxgc6eUUOnwiJVqHDi4NHAQfWoDJq4-L-p5Y6ziz6ptJU8G9aKDB8b5-GnmNmvin_-lBR1tm75FZDXefapi3Awg6dBhpbsZS6TqijepXz0L4XmmiXLCWJDrU/s1600/14-add-view-customer-details.png&quot; height=&quot;182&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
    &lt;/div&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;By Clicking on&amp;nbsp; “Add View” It displays popup and choose the setting as mentioned in the screen.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&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/AVvXsEhOoAvxllqAjoKi28Qhkl54Xvr4tSDK567BXe_Mhm32p6mXd72mHs4OKhtNuCErvpEn1G_0aTWYislgSgLtmumPCGjmQnG3GO_m7TEo42dT5bYwW6QlCvwSuVKYNiHryWRiemVdNWIC1f4/s1600/15-add-view-customer-details-template.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhOoAvxllqAjoKi28Qhkl54Xvr4tSDK567BXe_Mhm32p6mXd72mHs4OKhtNuCErvpEn1G_0aTWYislgSgLtmumPCGjmQnG3GO_m7TEo42dT5bYwW6QlCvwSuVKYNiHryWRiemVdNWIC1f4/s1600/15-add-view-customer-details-template.png&quot; height=&quot;392&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
    &lt;/div&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;b&gt;&amp;nbsp;Changes:&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;View name: Index&lt;br /&gt;Template: List (As we are going to display list of customer details)&lt;br /&gt;Model class: CustomerModel&lt;br /&gt;&lt;br /&gt;Click on “Add” button then the view will be created&amp;nbsp; and the displayed screen is as follows.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&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/AVvXsEhok5Dw-iCrOZ-VtPTrSYOm7EOvzZsorOIPlR8R4HWzb9YnBqZjqpuqUBbF17lKxGcGIg_BlBaXuXm9sJPKEBMXi9mx2fhYUncOeRksjb2ZkE1LKE4pQxXPQ80sOsdjh0LsmiXvuWTVOSE/s1600/16-created-view-details.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhok5Dw-iCrOZ-VtPTrSYOm7EOvzZsorOIPlR8R4HWzb9YnBqZjqpuqUBbF17lKxGcGIg_BlBaXuXm9sJPKEBMXi9mx2fhYUncOeRksjb2ZkE1LKE4pQxXPQ80sOsdjh0LsmiXvuWTVOSE/s1600/16-created-view-details.png&quot; height=&quot;344&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
    &lt;/div&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;Now, update the Index.cshtml with the following design.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;
@model IEnumerable&lt;MvcPartialViewResultDemo.Models.CustomerModel&gt;

@{
    ViewBag.Title = &quot;Index&quot;;
}
&lt;style type=&quot;text/css&quot;&gt;
    .customer th {
        text-align: center; 
    }
    .customer tr td {
        vertical-align: middle !important;
    }
&lt;/style&gt;

&lt;h2&gt;Customer Details&lt;/h2&gt;

&lt;p&gt;
    @Html.ActionLink(&quot;Create New&quot;, &quot;Create&quot;)
&lt;/p&gt;
&lt;table class=&quot;table customer&quot;&gt;
    @*Headers*@
    &lt;tr&gt;
        &lt;th&gt;
            @Html.DisplayNameFor(model =&gt; model.CustmerId)
        &lt;/th&gt;
        &lt;th&gt;
            @Html.DisplayNameFor(model =&gt; model.CustomerName)
        &lt;/th&gt;
        &lt;th&gt;
            @Html.DisplayNameFor(model =&gt; model.PresentAddress)
        &lt;/th&gt;
        &lt;th&gt;
            @Html.DisplayNameFor(model =&gt; model.PermanantAddress)
        &lt;/th&gt;
        &lt;th&gt;&lt;/th&gt;
    &lt;/tr&gt;
    
    @*Customer Data*@
    @foreach (var item in Model) {
        &lt;tr&gt;
            &lt;td&gt;
                @Html.DisplayFor(modelItem =&gt; item.CustmerId)
            &lt;/td&gt;
            &lt;td&gt;
                @Html.DisplayFor(modelItem =&gt; item.CustomerName)
            &lt;/td&gt;
            &lt;td&gt;
                @Html.Partial(&quot;_CustomerAddressDetails&quot;,item.PresentAddress)
            &lt;/td&gt;
            &lt;td&gt;
                @Html.Partial(&quot;_CustomerAddressDetails&quot;, item.PermanantAddress)
            &lt;/td&gt;
            &lt;td&gt;
                @Html.ActionLink(&quot;Edit&quot;, &quot;Edit&quot;, new { id=item.CustmerId }) |
                @Html.ActionLink(&quot;Details&quot;, &quot;Details&quot;, new { id = item.CustmerId }) |
                @Html.ActionLink(&quot;Delete&quot;, &quot;Delete&quot;, new { id = item.CustmerId })
            &lt;/td&gt;
        &lt;/tr&gt;
    }

&lt;/table&gt;

&lt;/pre&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;The Index.cshtml file displays as follows.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&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/AVvXsEg8U4e4mNyMcQhLYB-sJEpm1iiMdYXF77AU-6uhRzXyzrYKERIQN29NlCHwJA24C_ITPYdX_2dIF0ZQ22xVTmLjoaQ1Gee2eSWgJitQxuMgMC7jd_Yl_NZM2wAGZd8_fMOWc42gvQ_RTc4/s1600/19-details-view-with-partial-view.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8U4e4mNyMcQhLYB-sJEpm1iiMdYXF77AU-6uhRzXyzrYKERIQN29NlCHwJA24C_ITPYdX_2dIF0ZQ22xVTmLjoaQ1Gee2eSWgJitQxuMgMC7jd_Yl_NZM2wAGZd8_fMOWc42gvQ_RTc4/s1600/19-details-view-with-partial-view.png&quot; height=&quot;328&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&amp;nbsp;Step 8:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now, open the CustomerController.cs file and add the code as follows to get the list of customer details.&lt;br /&gt;&lt;br /&gt;Add a namespace as like below.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;using MvcPartialViewResultDemo.Models;
&lt;/pre&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;to the CustomerController.cs file and then add the following method to CustomerController.cs file&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;
public List&lt;CustomerModel&gt; GetCustomerDetails()
        {
            var customerList = new List&lt;CustomerModel&gt;();
            for (int i = 1; i &amp;lt;= 2; i++)
            {
                var customer = new CustomerModel
                {
                    CustmerId = i,
                    CustomerName = string.Concat(&quot;Customer&quot;, i),
                    PermanantAddress = new CustomerAddress()
                    {
                        DoorNumber = string.Concat(&quot;Permanent-D.No:4-xx-&quot;, i),
                        City = string.Concat(&quot;Permanent-City&quot;, i),
                        State = string.Concat(&quot;Permanent-State&quot;, i),
                        PinNumber = string.Concat(&quot;Permanent-Pin&quot;, i)
                    },
                    PresentAddress = new CustomerAddress()
                    {
                        DoorNumber = string.Concat(&quot;Present-D.No:4-xx-&quot;, i),
                        City = string.Concat(&quot;Present-City&quot;, i),
                        State = string.Concat(&quot;Present-State&quot;, i),
                        PinNumber = string.Concat(&quot;Present-Pin&quot;, i)
                    }
                };
                customerList.Add(customer);
            }
            return customerList;
        }
&lt;/pre&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;and then update the Index action method code as follows.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt; // GET: Customer
        public ActionResult Index()
        {
            var customerDetails = GetCustomerDetails();
            return View(customerDetails);
        }
&lt;/pre&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Now, you can build the application( Ctrl+Shift+B), After a few moments it should be “Build succeeded” then run the application by hitting F5 and then change browser URL (&lt;br /&gt;http://localhost:60385/Customer/Index ) The output screen is as follows.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVLY2FvLduwlEEUzg6azI9LlED6XB6LZruh6-pfwivupKPtciC6MS-K69YSdmLNdecYz011ZhC2SJ4x0xKph8OIV9lekixUCrM0t_-SN0IexUuv9pXYafpSeDJUU6EgWxBhfWzwJ0NYS0/s1600/20-customer-details-display.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhVLY2FvLduwlEEUzg6azI9LlED6XB6LZruh6-pfwivupKPtciC6MS-K69YSdmLNdecYz011ZhC2SJ4x0xKph8OIV9lekixUCrM0t_-SN0IexUuv9pXYafpSeDJUU6EgWxBhfWzwJ0NYS0/s1600/20-customer-details-display.png&quot; height=&quot;266&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;As of now, you are able to display the customer details. Now, you can work on Details of each specific customer.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;Step 9:&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Go to the CustomerController.cs file and add a “view” for the Action method Details.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&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/AVvXsEhu0T8kqUJANXdJ7mzcVD1D0EcedUUpCQ_1NB76a_xZAChINirTp1VbsR1iY69yh5iHjI6S02IsMWckvsYIJU063J5iXPCg0H-ZUtZ4R_n9WRLXMRiDro6-Qv47GzyL74_q-OjNqlsDJ1Q/s1600/21-Details-action-add-view.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhu0T8kqUJANXdJ7mzcVD1D0EcedUUpCQ_1NB76a_xZAChINirTp1VbsR1iY69yh5iHjI6S02IsMWckvsYIJU063J5iXPCg0H-ZUtZ4R_n9WRLXMRiDro6-Qv47GzyL74_q-OjNqlsDJ1Q/s1600/21-Details-action-add-view.png&quot; height=&quot;118&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
        &lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;The view template is as follows.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&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/AVvXsEhtJlmsyfIar2qd3-MqdqRQ4AsryqUkeaVCvhGIF91JVSYq3DZOUQPuvGdstJO4fFDGukLRPPSmDOmW5UA3DDz5-UT-wK6GHgR_68QopCvjM9B-yM8d7a4aL-M9QZYXuJAguEY5k1T3PU0/s1600/22-details-view-template.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtJlmsyfIar2qd3-MqdqRQ4AsryqUkeaVCvhGIF91JVSYq3DZOUQPuvGdstJO4fFDGukLRPPSmDOmW5UA3DDz5-UT-wK6GHgR_68QopCvjM9B-yM8d7a4aL-M9QZYXuJAguEY5k1T3PU0/s1600/22-details-view-template.png&quot; height=&quot;392&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
        &lt;/div&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Click on “Add” button and then delete and update the design html is as follows.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;@model MvcPartialViewResultDemo.Models.CustomerModel
@{
    ViewBag.Title = &quot;Details&quot;;
}
&lt;h2&gt;
Customer Details&lt;/h2&gt;
&lt;div&gt;

&lt;dl class=&quot;dl-horizontal&quot;&gt;
&lt;dt&gt;
            @Html.DisplayNameFor(model =&amp;gt; model.CustmerId)
        &lt;/dt&gt;
&lt;dd&gt;@Html.DisplayFor(model =&amp;gt; model.CustmerId)
        &lt;/dd&gt;
&lt;dt&gt;
            @Html.DisplayNameFor(model =&amp;gt; model.CustomerName)
        &lt;/dt&gt;
&lt;dd&gt;@Html.DisplayFor(model =&amp;gt; model.CustomerName)
        &lt;/dd&gt;
        @Html.Partial(&quot;_CustomerAddressDetails&quot;, Model.PermanantAddress)
    
        @Html.Partial(&quot;_CustomerAddressDetails&quot;, Model.PresentAddress)
    &lt;/dl&gt;
&lt;/div&gt;
@Html.ActionLink(&quot;Edit&quot;, &quot;Edit&quot;, new { id = Model.CustmerId }) |
    @Html.ActionLink(&quot;Back to List&quot;, &quot;Index&quot;)
&lt;/pre&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;Step 10:&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Now, Add the method GetCustomerById to the CustomerController.cs file is as follows.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;public CustomerModel GetCustomerById(int customerId)
        {
            var customerDetails = GetCustomerDetails();
            var customer = (from cust in customerDetails
                where cust.CustmerId == customerId
                select cust).FirstOrDefault();
            return customer;
        }
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Now, Update a details action method for CustomController.cs file.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;// GET: Customer/Details/5
        public ActionResult Details(int id)
        {
            var customerModel = GetCustomerById(id);
            return View(customerModel);
        }
&lt;/pre&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Build the solution and then hit the “F5” button to see the result by navigating to the URL http://localhost:60385/Customer/Details/1.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&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/AVvXsEgRNkX779AZdG4z2PqTdyXkXGVFLLollqcmGzm9BtDjs3YMJNanRxhF75q2vxxvSSorF68dqY_Q506wfKHcjXEwAFnCwGIuW7lfHHX4juHy22cqR7NuFtFSpVVJAMi0e6WFjeu26z6ckdc/s1600/24-customer-detials-display-output.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRNkX779AZdG4z2PqTdyXkXGVFLLollqcmGzm9BtDjs3YMJNanRxhF75q2vxxvSSorF68dqY_Q506wfKHcjXEwAFnCwGIuW7lfHHX4juHy22cqR7NuFtFSpVVJAMi0e6WFjeu26z6ckdc/s1600/24-customer-detials-display-output.png&quot; height=&quot;232&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
        &lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;Step 11:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now, Create another partial view to manage the edit/create operations for customer address. The flow for the screen shots is as below.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&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/AVvXsEhdW93QlXMyeLnYXxn5azLzhjAjSntyuMekWBsEmeyZyQ8B2T53CSRg47UtzJfO4lKjNfYIdJQJWE-Npj38TRcGrkrl1t1faf_MZvdL0niA0B1LzEIfPkxUAk5isrwAmBBp8bKtSr5-ybw/s1600/27-customer-address-create-partialview-step1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdW93QlXMyeLnYXxn5azLzhjAjSntyuMekWBsEmeyZyQ8B2T53CSRg47UtzJfO4lKjNfYIdJQJWE-Npj38TRcGrkrl1t1faf_MZvdL0niA0B1LzEIfPkxUAk5isrwAmBBp8bKtSr5-ybw/s1600/27-customer-address-create-partialview-step1.png&quot; height=&quot;368&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&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/AVvXsEhPSly2zpR1vkYsUIUGlXln8c8f8l3KQkYf626ou56dP74bowXnNjqaLwr7PPUVmC3fBoown5bUZGt_E1cafSVwkw5N1e0t0ORiqs-PJo8Z2MI8ol6I_yKP4b-rqhGOGTLsdZzHpn1jChE/s1600/28-customer-address-create-partialview-step2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhPSly2zpR1vkYsUIUGlXln8c8f8l3KQkYf626ou56dP74bowXnNjqaLwr7PPUVmC3fBoown5bUZGt_E1cafSVwkw5N1e0t0ORiqs-PJo8Z2MI8ol6I_yKP4b-rqhGOGTLsdZzHpn1jChE/s1600/28-customer-address-create-partialview-step2.png&quot; height=&quot;392&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;By Clicking on &quot;Add&quot; button &quot;_CustomerAddress.cshtml&quot; file would be created and then replace the design with the following below.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #b45f06;&quot;&gt;
            &lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;
                &lt;span style=&quot;font-size: medium;&quot;&gt;
                    &lt;span style=&quot;color: black;&quot;&gt;
                        &lt;br /&gt;
                    &lt;/span&gt;
                &lt;/span&gt;
            &lt;/span&gt;
        &lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;
@model MvcPartialViewResultDemo.Models.CustomerAddress
    
&lt;div class=&quot;form-horizontal&quot;&gt;
&lt;hr /&gt;
@Html.ValidationSummary(true, &quot;&quot;, new { @class = &quot;text-danger&quot; })
        &lt;br /&gt;
&lt;div class=&quot;form-group&quot;&gt;
@Html.LabelFor(model =&amp;gt; model.DoorNumber, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
        &lt;br /&gt;
&lt;div class=&quot;col-md-10&quot;&gt;
@Html.EditorFor(model =&amp;gt; model.DoorNumber, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
            @Html.ValidationMessageFor(model =&amp;gt; model.DoorNumber, &quot;&quot;, new { @class = &quot;text-danger&quot; })
        &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;form-group&quot;&gt;
@Html.LabelFor(model =&amp;gt; model.City, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
        &lt;br /&gt;
&lt;div class=&quot;col-md-10&quot;&gt;
@Html.EditorFor(model =&amp;gt; model.City, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
            @Html.ValidationMessageFor(model =&amp;gt; model.City, &quot;&quot;, new { @class = &quot;text-danger&quot; })
        &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;form-group&quot;&gt;
@Html.LabelFor(model =&amp;gt; model.State, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
        &lt;br /&gt;
&lt;div class=&quot;col-md-10&quot;&gt;
@Html.EditorFor(model =&amp;gt; model.State, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
            @Html.ValidationMessageFor(model =&amp;gt; model.State, &quot;&quot;, new { @class = &quot;text-danger&quot; })
        &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;form-group&quot;&gt;
@Html.LabelFor(model =&amp;gt; model.PinNumber, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
        &lt;br /&gt;
&lt;div class=&quot;col-md-10&quot;&gt;
@Html.EditorFor(model =&amp;gt; model.PinNumber, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
            @Html.ValidationMessageFor(model =&amp;gt; model.PinNumber, &quot;&quot;, new { @class = &quot;text-danger&quot; })
        &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;
            &lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;
                &lt;span style=&quot;font-size: medium;&quot;&gt;
                    &lt;span style=&quot;color: black;&quot;&gt;
                    &lt;/span&gt;
                &lt;/span&gt;
            &lt;/span&gt;
        &lt;/span&gt;
        &lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;Step 12:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Open CustomerController.cs file and update the Get Edit Action method with the below code.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;/div&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;// GET: Customer/Edit/5
        public ActionResult Edit(int id)
        {
            var customerModel = GetCustomerById(id);
            return View(customerModel);
        }
&lt;/pre&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;and then add a view for the Edit method like the below.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiroDsj9_UrjI3LhGaRTqig8bfJOhrba3NibSVGxOxMzCQz8chKwYInSspP6-WiYE0LBfPJ33wg200Olf2wK7dDyJpM0hvwy2Mour4YDAjNDe_guHpOzwGPRX-26QzOxJhSMbtk64oV7QQ/s1600/25-edit-view-creation.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiroDsj9_UrjI3LhGaRTqig8bfJOhrba3NibSVGxOxMzCQz8chKwYInSspP6-WiYE0LBfPJ33wg200Olf2wK7dDyJpM0hvwy2Mour4YDAjNDe_guHpOzwGPRX-26QzOxJhSMbtk64oV7QQ/s1600/25-edit-view-creation.png&quot; height=&quot;114&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbdKksls07aQHHNz3f4XKyoHZ7SnVRoPrBbZX5Sbqgr3QxZv3BnBnaGbhpTINn4QQhnGzhWD9FUw4ixBPGhitoeaSe0HnDK1YhcqhST6DLSIOgLpA_r_3ZNymRdoEjqn821uorrtlEhcQ/s1600/26-edit-view-creation-template.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhbdKksls07aQHHNz3f4XKyoHZ7SnVRoPrBbZX5Sbqgr3QxZv3BnBnaGbhpTINn4QQhnGzhWD9FUw4ixBPGhitoeaSe0HnDK1YhcqhST6DLSIOgLpA_r_3ZNymRdoEjqn821uorrtlEhcQ/s1600/26-edit-view-creation-template.png&quot; height=&quot;392&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;After that, update the Edit.cshtml&amp;nbsp; with the following html design&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;br /&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;@model MvcPartialViewResultDemo.Models.CustomerModel
@{
    ViewBag.Title = &quot;Edit&quot;;
}
&lt;h2&gt;
Edit&lt;/h2&gt;
@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()
        &lt;div class=&quot;form-horizontal&quot;&gt;
@Html.ValidationSummary(true, &quot;&quot;, new { @class = &quot;text-danger&quot; })
        &lt;br /&gt;
&lt;div class=&quot;form-group&quot;&gt;
@Html.LabelFor(model =&amp;gt; model.CustmerId, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
        &lt;br /&gt;
&lt;div class=&quot;col-md-10&quot;&gt;
@Html.TextBoxFor(model =&amp;gt; model.CustmerId, new { @class = &quot;form-control&quot;, disabled = &quot;disabled&quot;, @readonly = &quot;readonly&quot; })
            &lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;form-group&quot;&gt;
@Html.LabelFor(model =&amp;gt; model.CustomerName, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
        &lt;br /&gt;
&lt;div class=&quot;col-md-10&quot;&gt;
@Html.EditorFor(model =&amp;gt; model.CustomerName, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
                @Html.ValidationMessageFor(model =&amp;gt; model.CustomerName, &quot;&quot;, new { @class = &quot;text-danger&quot; })
            &lt;/div&gt;
&lt;/div&gt;
&lt;h4&gt;
Permanent Address:&lt;/h4&gt;
@Html.Partial(&quot;_CustomerAddress&quot;, Model.PermanantAddress)
        &lt;br /&gt;
&lt;h4&gt;
Present Address:&lt;/h4&gt;
@Html.Partial(&quot;_CustomerAddress&quot;, Model.PresentAddress)
        &lt;br /&gt;
&lt;div class=&quot;form-group&quot;&gt;
&lt;div class=&quot;col-md-offset-2 col-md-10&quot;&gt;
&lt;input class=&quot;btn btn-default&quot; type=&quot;submit&quot; value=&quot;Save&quot; /&gt;
            &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
}
&lt;div&gt;
@Html.ActionLink(&quot;Back to List&quot;, &quot;Index&quot;)
&lt;/div&gt;
&lt;/pre&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;b&gt;Changes: &lt;/b&gt;&lt;br /&gt;Disable the customer id&lt;br /&gt;Include the _CustomerAddress.cshtml partial view&lt;br /&gt;&lt;br /&gt;Now, update the Post method of Edit action in CustomerController.cs code as below.&lt;br /&gt;&lt;br /&gt;Post method of Edit action controller code.&lt;br /&gt;&lt;br /&gt;Build the application and hit F5, Navigate to&amp;nbsp; http://localhost:60385/Customer click on any Edit link of the customer and then update the data like the below.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr0oc8MMbP9XEPChOML0vl-ANNshDJf1gPWoSJYqAYf_z0ad3inpIUNzW9o0pGGspBZAoySr3mpYrPZzpSIrQ-aR7BikVf-7UVvESmm633pNRn99QSjqoHvdmmpO7tyiHz_WEVxa1c4s4/s1600/29-customer-edit-functionality.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhr0oc8MMbP9XEPChOML0vl-ANNshDJf1gPWoSJYqAYf_z0ad3inpIUNzW9o0pGGspBZAoySr3mpYrPZzpSIrQ-aR7BikVf-7UVvESmm633pNRn99QSjqoHvdmmpO7tyiHz_WEVxa1c4s4/s1600/29-customer-edit-functionality.png&quot; height=&quot;378&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;After updating the details by click on “Save” button it goes to the&amp;nbsp; post action of Edit method and I have captured the field values while in debugging mode for reference.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&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/AVvXsEg9zF4eoTmwYQ5ggBjCVke-Qfy8_WOhXNlcRj7bB7U5PF6jgbUP67Rlzv4n2_SEyRjT5ywROC0HVqyzAuOJpSSM2_Y9UbE3U0_LWs9SlA8SlhgCknUCljTqa5N-0eVdiddsUMaYh0LO1JM/s1600/30-customer-details-update-details.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg9zF4eoTmwYQ5ggBjCVke-Qfy8_WOhXNlcRj7bB7U5PF6jgbUP67Rlzv4n2_SEyRjT5ywROC0HVqyzAuOJpSSM2_Y9UbE3U0_LWs9SlA8SlhgCknUCljTqa5N-0eVdiddsUMaYh0LO1JM/s1600/30-customer-details-update-details.png&quot; height=&quot;354&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;As, you observed the Post method of Edit contains two parameters one for CustomerId and another for get the all form control values.&lt;br /&gt;&lt;br /&gt;So, FormCollection is being used to get all the control values. As you are used one partial view two times in a form to get the permanent and present address details. The FormCollection values are comes with “,” separator.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;Step 13:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Add a view named as “Create.cshtml” from the get action method “Create” in customerController.cs file is as follows.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&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/AVvXsEjl34jljMHGuVPpYOgfl9i253tGxAJKj6UyIyvZ7SM4of-z4HDuX6B4iSAmT8NWA4D9gUeW0vdnv7B42LITmM-Az7GrEEXIi09yMgeUPNuy-fmiBUbNtzK88RZZ22i-ymHY_Jzw3OquGCc/s1600/31-create-customer-step1.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjl34jljMHGuVPpYOgfl9i253tGxAJKj6UyIyvZ7SM4of-z4HDuX6B4iSAmT8NWA4D9gUeW0vdnv7B42LITmM-Az7GrEEXIi09yMgeUPNuy-fmiBUbNtzK88RZZ22i-ymHY_Jzw3OquGCc/s1600/31-create-customer-step1.png&quot; height=&quot;124&quot; width=&quot;600&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/AVvXsEgwnAyczbTsDPrd7-7dRGpYJDLatmWGKaez0diVZYQqJBmCvlnXlvYgzu9UlVQUTmo4vi5_LEGkLCfBAb6PmW3eEZ5zpM3l5Q_XDXu-HJf5Duj9Xo6pQDKGjMQgRrmOuJZ5X7y9ggRduBI/s1600/32-create-customer-step2.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgwnAyczbTsDPrd7-7dRGpYJDLatmWGKaez0diVZYQqJBmCvlnXlvYgzu9UlVQUTmo4vi5_LEGkLCfBAb6PmW3eEZ5zpM3l5Q_XDXu-HJf5Duj9Xo6pQDKGjMQgRrmOuJZ5X7y9ggRduBI/s1600/32-create-customer-step2.png&quot; height=&quot;392&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;
        &lt;/div&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;And then update the design by including Partial views is as follows.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;br /&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;@model MvcPartialViewResultDemo.Models.CustomerModel
@{
    ViewBag.Title = &quot;Create&quot;;
}
&lt;h2&gt;
Create&lt;/h2&gt;
@using (Html.BeginForm()) 
{
    @Html.AntiForgeryToken()
    
        &lt;div class=&quot;form-horizontal&quot;&gt;
&lt;h4&gt;
CustomerModel&lt;/h4&gt;
&lt;hr /&gt;
@Html.ValidationSummary(true, &quot;&quot;, new { @class = &quot;text-danger&quot; })
        @*&lt;br /&gt;
&lt;div class=&quot;form-group&quot;&gt;
@Html.LabelFor(model =&amp;gt; model.CustmerId, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
        &lt;br /&gt;
&lt;div class=&quot;col-md-10&quot;&gt;
@Html.EditorFor(model =&amp;gt; model.CustmerId, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
                @Html.ValidationMessageFor(model =&amp;gt; model.CustmerId, &quot;&quot;, new { @class = &quot;text-danger&quot; })
            &lt;/div&gt;
&lt;/div&gt;
*@
        &lt;br /&gt;
&lt;div class=&quot;form-group&quot;&gt;
@Html.LabelFor(model =&amp;gt; model.CustomerName, htmlAttributes: new { @class = &quot;control-label col-md-2&quot; })
        &lt;br /&gt;
&lt;div class=&quot;col-md-10&quot;&gt;
@Html.EditorFor(model =&amp;gt; model.CustomerName, new { htmlAttributes = new { @class = &quot;form-control&quot; } })
                @Html.ValidationMessageFor(model =&amp;gt; model.CustomerName, &quot;&quot;, new { @class = &quot;text-danger&quot; })
            &lt;/div&gt;
&lt;/div&gt;
&lt;h4&gt;
Permanent Address:&lt;/h4&gt;
@Html.Partial(&quot;_CustomerAddress&quot;)
        &lt;br /&gt;
&lt;h4&gt;
Present Address:&lt;/h4&gt;
@Html.Partial(&quot;_CustomerAddress&quot;)
        &lt;br /&gt;
&lt;div class=&quot;form-group&quot;&gt;
&lt;div class=&quot;col-md-offset-2 col-md-10&quot;&gt;
&lt;input class=&quot;btn btn-default&quot; type=&quot;submit&quot; value=&quot;Create&quot; /&gt;
            &lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
}
&lt;div&gt;
@Html.ActionLink(&quot;Back to List&quot;, &quot;Index&quot;)
&lt;/div&gt;
&lt;/pre&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;After that, update the code in Post Create Action method is as follows.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;// POST: Customer/Create
        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                var customerModel = new CustomerModel
                {
                    CustmerId =  5, //Get the max+1 from customer list
                    CustomerName = collection[&quot;CustomerName&quot;],
                    PermanantAddress = new CustomerAddress()
                    {
                        DoorNumber = collection[&quot;DoorNumber&quot;].Split(&#39;,&#39;)[0],
                        City = collection[&quot;City&quot;].Split(&#39;,&#39;)[0],
                        State = collection[&quot;State&quot;].Split(&#39;,&#39;)[0],
                        PinNumber = collection[&quot;PinNumber&quot;].Split(&#39;,&#39;)[0]
                    },
                    PresentAddress = new CustomerAddress()
                    {
                        DoorNumber = collection[&quot;DoorNumber&quot;].Split(&#39;,&#39;)[1],
                        City = collection[&quot;City&quot;].Split(&#39;,&#39;)[1],
                        State = collection[&quot;State&quot;].Split(&#39;,&#39;)[1],
                        PinNumber = collection[&quot;PinNumber&quot;].Split(&#39;,&#39;)[1]
                    }
                };
                // TODO: Add insert logic here
                return RedirectToAction(&quot;Index&quot;);
            }
            catch
            {
                return View();
            }
        }
&lt;/pre&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Now, you are ready with the Create functionality of Customers as well. Just hit F5 and then click on “Create New” customer link then fill the details as you required.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCr3T7QW3w7iShnjpngWHD5avxN0uFDz08kM6l63uqAfpVi93HpqpZQOp-C7JiCybJEKJJ8sOn3WoxEv-ABZzgxfJm_G0m3zP_Woxn1JtHEeeaFaIyhvQEoK3Nwsd1wG8gwV-NpIn25H8/s1600/33-create-customer-step3.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjCr3T7QW3w7iShnjpngWHD5avxN0uFDz08kM6l63uqAfpVi93HpqpZQOp-C7JiCybJEKJJ8sOn3WoxEv-ABZzgxfJm_G0m3zP_Woxn1JtHEeeaFaIyhvQEoK3Nwsd1wG8gwV-NpIn25H8/s1600/33-create-customer-step3.png&quot; height=&quot;382&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;After entering the details, click on Save button to save the details.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&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/AVvXsEhKPrBI8Nvr5mbOeSDKnbh_IRPau-ViZYNJiRerfsTaKr6xMfioxyc_WbUbA9Z5T0wdC-lfw2AgByHfWQdXWn-jSh1fABshjK-6dI1vQTWL-Pnl82rguvExdaSfMB0B5W2kb5zx0W9WgmY/s1600/34-save-customer-details.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhKPrBI8Nvr5mbOeSDKnbh_IRPau-ViZYNJiRerfsTaKr6xMfioxyc_WbUbA9Z5T0wdC-lfw2AgByHfWQdXWn-jSh1fABshjK-6dI1vQTWL-Pnl82rguvExdaSfMB0B5W2kb5zx0W9WgmY/s1600/34-save-customer-details.png&quot; height=&quot;354&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;As you noticed in the above image, you would get the all details then you just need to send that customer model object to the database call to save the details.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;Step 14:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Add a view named as “Delete.csthml”&amp;nbsp; from the get action method named as “Delete” in CustomerController.cs file.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsaDzxj7gO8e-TstuSMRYPdU_hsc8ex6PNy90iR2W_HLeC-04mHKzQzg9RTcjc7ls0SaPsAKbwRzsGjfRZ0M_4VYmN3d3KF5TOOPYu1nP-0K26N9jocH9G_O5-DoC0QSK0VRIwiJkwWLA/s1600/35-delete-view-step1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgsaDzxj7gO8e-TstuSMRYPdU_hsc8ex6PNy90iR2W_HLeC-04mHKzQzg9RTcjc7ls0SaPsAKbwRzsGjfRZ0M_4VYmN3d3KF5TOOPYu1nP-0K26N9jocH9G_O5-DoC0QSK0VRIwiJkwWLA/s1600/35-delete-view-step1.png&quot; height=&quot;92&quot; width=&quot;600&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;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjTPJSYq2w-nzm0_Am-njKIZXt3amqyt6BuDPm5tOr7wPguP8kDUfVSGsD11RSoWFmptJvEGQnFAyIXRT8VlDL4DMY5Q-DsVhD0XNJS05E5kYrUPPb9h8r4yG7ST32WYtLTcE3G7WkaPE/s1600/36-delete-view-step2.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjTPJSYq2w-nzm0_Am-njKIZXt3amqyt6BuDPm5tOr7wPguP8kDUfVSGsD11RSoWFmptJvEGQnFAyIXRT8VlDL4DMY5Q-DsVhD0XNJS05E5kYrUPPb9h8r4yG7ST32WYtLTcE3G7WkaPE/s1600/36-delete-view-step2.png&quot; height=&quot;392&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;And then update the design by including Partial views is as follows.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;@model MvcPartialViewResultDemo.Models.CustomerModel
@{
    ViewBag.Title = &quot;Delete&quot;;
}
&lt;h2&gt;
Delete&lt;/h2&gt;
&lt;h3&gt;
Are you sure you want to delete this?&lt;/h3&gt;
&lt;div&gt;
&lt;hr /&gt;

&lt;dl class=&quot;dl-horizontal&quot;&gt;
&lt;dt&gt;
            @Html.DisplayNameFor(model =&amp;gt; model.CustmerId)
        &lt;/dt&gt;
&lt;dd&gt;@Html.DisplayFor(model =&amp;gt; model.CustmerId)
        &lt;/dd&gt;
&lt;dt&gt;
            @Html.DisplayNameFor(model =&amp;gt; model.CustomerName)
        &lt;/dt&gt;
&lt;dd&gt;@Html.DisplayFor(model =&amp;gt; model.CustomerName)
        &lt;/dd&gt;
        
        @Html.Partial(&quot;_CustomerAddressDetails&quot;, Model.PermanantAddress)
        @Html.Partial(&quot;_CustomerAddressDetails&quot;, Model.PresentAddress)
    &lt;/dl&gt;
@using (Html.BeginForm()) {
        @Html.AntiForgeryToken()
        &lt;br /&gt;
&lt;div class=&quot;form-actions no-color&quot;&gt;
&lt;input class=&quot;btn btn-default&quot; type=&quot;submit&quot; value=&quot;Delete&quot; /&gt; |
            @Html.ActionLink(&quot;Back to List&quot;, &quot;Index&quot;)
        &lt;/div&gt;
}
&lt;/div&gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Update the code in get&amp;nbsp; Delete&amp;nbsp; action method is as follows.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt; // GET: Customer/Delete/5
        public ActionResult Delete(int id)
        {
            var customerModel = GetCustomerById(id);
            return View(customerModel);
        }
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Update the code in post delete action method is as follows.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;CSHARP&quot; name=&quot;code&quot;&gt;// POST: Customer/Delete/5
        [HttpPost]
        public ActionResult Delete(int id, FormCollection collection)
        {
            try
            {
                if (id &amp;gt; 0)
                {
                    // TODO: Add delete logic here
                }
                return RedirectToAction(&quot;Index&quot;);
            }
            catch
            {
                return View();
            }
        }
&lt;/pre&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;Build the application and hit F5 button then navigate to the “http://localhost:60385/Customer/Index” and then click on delete link to delete the customer as you desired. The delete customer output is as follows.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&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/AVvXsEhdzDvKygqUl86q01Ux1na0m6-B8N1OyNBil2aDsPgPAwSMKkap7KuGyIWTNNN3J2lgVsaqUsZ4KTK8uIMrnh9epoj4aDd6CroK7xOVGVzVKF4Vl0i3lsfjFZ8WBBh9yaJ41xYJAOOywPU/s1600/37-delete-view-step3.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhdzDvKygqUl86q01Ux1na0m6-B8N1OyNBil2aDsPgPAwSMKkap7KuGyIWTNNN3J2lgVsaqUsZ4KTK8uIMrnh9epoj4aDd6CroK7xOVGVzVKF4Vl0i3lsfjFZ8WBBh9yaJ41xYJAOOywPU/s1600/37-delete-view-step3.png&quot; height=&quot;456&quot; width=&quot;600&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/AVvXsEjzZvGHlYfod5eCDqHIWnro5TlbgJWqeSKXsiJnhJb6iIzzg4P-cIx6ot0WGS4PUc36FWU7imOdGfe6ounP2es5mqmDwdyZovj88CSIkrO8J7XUxBedhJ5LWD9VecvhyphenhyphenzQJPCSfelSsRDk/s1600/38-delete-view-step4.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzZvGHlYfod5eCDqHIWnro5TlbgJWqeSKXsiJnhJb6iIzzg4P-cIx6ot0WGS4PUc36FWU7imOdGfe6ounP2es5mqmDwdyZovj88CSIkrO8J7XUxBedhJ5LWD9VecvhyphenhyphenzQJPCSfelSsRDk/s1600/38-delete-view-step4.png&quot; height=&quot;352&quot; width=&quot;600&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;As you observed the above image you are getting the customer id then you can perform the database call to delete the customer.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;font-family: Times New Roman, serif;&quot;&gt;&lt;span style=&quot;font-size: medium;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;Conclusion:&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;I hope this above example gives you a brief idea on usage of partial views with a sample application of customer related operations(Details, Display, Create, Edit and Delete) and also you can get some idea how can you create sample application by using MVC.&lt;br /&gt;&lt;br /&gt;Please provide your valuable suggestions and feedback if&amp;nbsp; any.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
    &lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/5078866103907718098/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2014/09/partial-view-result-sample-web-app-in-mvc.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/5078866103907718098'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/5078866103907718098'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2014/09/partial-view-result-sample-web-app-in-mvc.html' title='Partial View Result Return Type in MVC 5 with sample Web application'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/AVvXsEgxefF888uv1-5eAk10Zo-LNvSbzxrtoKrPvqP7xWhnJPpsQPFp3m0gvYvEZ0x-M9xBOv7EyOT8VHaU86s3bnV59wzX8QNz218J7ueZ1nPJQJVMQgxM2tmlWniihyu5OLsrJnRPaGf0TBo/s72-c/01-start-project-2013.png" height="72" width="72"/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-4732615359723305686</id><published>2014-09-10T00:48:00.001+05:30</published><updated>2014-09-10T00:48:55.430+05:30</updated><title type='text'>ZenCoding and Lorem pixel generator in .NET</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;b&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;ZenCoding&lt;/span&gt;&lt;/b&gt;&lt;/h3&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;/div&gt;&lt;br/&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
ZenCoding is the one of the greatest
feature (at least I feel) in the Web essentials.  It helps you a lot
to write HTML code in fastest way even visual studio 2013 provides
itself a lot of features like (automatically closes (or
modify/update) the tag when you write start tag and etc). 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
You can use the ZenCoding by
installing from &lt;a href=&quot;http://vswebessentials.com/features/html&quot; target=&quot;_blank&quot;&gt;Web Essentials&lt;/a&gt; site or 
&lt;a href=&quot;http://visualstudiogallery.msdn.microsoft.com/56633663-6799-41d7-9df7-0f2a504ca361&quot; target=&quot;_blank&quot;&gt;
visual studio gallery&lt;/a&gt; into Visual Studio.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
Zen coding is very much easy to
implement as you have some idea on CSS stuff.  It uses the syntax
like CSS selectors. The selectors are&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;table align=&quot;center&quot; border=&quot;1&quot; cellpadding=&quot;4&quot; cellspacing=&quot;0&quot; style=&quot;margin-left: 0px; margin-right: 0px; text-align: left; width: 100%px;&quot;&gt;
	&lt;colgroup&gt;&lt;col width=&quot;128*&quot;&gt;&lt;/col&gt;
	&lt;col width=&quot;128*&quot;&gt;&lt;/col&gt;
	&lt;/colgroup&gt;&lt;tbody&gt;
&lt;tr valign=&quot;TOP&quot;&gt;
		&lt;td width=&quot;50%&quot;&gt;&lt;div align=&quot;CENTER&quot;&gt;
&lt;b&gt;Selector&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
		&lt;td width=&quot;50%&quot;&gt;&lt;div align=&quot;CENTER&quot;&gt;
&lt;b&gt;Usage&lt;/b&gt;&lt;/div&gt;
&lt;/td&gt;
	&lt;/tr&gt;
&lt;tr valign=&quot;TOP&quot;&gt;
		&lt;td width=&quot;50%&quot;&gt;#&lt;/td&gt;
		&lt;td width=&quot;50%&quot;&gt;Id&lt;/td&gt;
	&lt;/tr&gt;
&lt;tr valign=&quot;TOP&quot;&gt;
		&lt;td width=&quot;50%&quot;&gt;.&lt;/td&gt;
		&lt;td width=&quot;50%&quot;&gt;class&lt;/td&gt;
	&lt;/tr&gt;
&lt;tr valign=&quot;TOP&quot;&gt;
		&lt;td width=&quot;50%&quot;&gt;&amp;gt;&lt;/td&gt;
		&lt;td width=&quot;50%&quot;&gt;Child element&lt;/td&gt;
	&lt;/tr&gt;
&lt;tr valign=&quot;TOP&quot;&gt;
		&lt;td width=&quot;50%&quot;&gt;^&lt;/td&gt;
		&lt;td width=&quot;50%&quot;&gt;Climbs Up&lt;/td&gt;
	&lt;/tr&gt;
&lt;tr valign=&quot;TOP&quot;&gt;
		&lt;td width=&quot;50%&quot;&gt;*&lt;/td&gt;
		&lt;td width=&quot;50%&quot;&gt;Multiplication&lt;/td&gt;
	&lt;/tr&gt;
&lt;tr valign=&quot;TOP&quot;&gt;
		&lt;td width=&quot;50%&quot;&gt;+&lt;/td&gt;
		&lt;td width=&quot;50%&quot;&gt;Sibling element&lt;/td&gt;
	&lt;/tr&gt;
&lt;tr valign=&quot;TOP&quot;&gt;
		&lt;td width=&quot;50%&quot;&gt;[]&lt;/td&gt;
		&lt;td width=&quot;50%&quot;&gt;Custom Attribute&lt;/td&gt;
	&lt;/tr&gt;
&lt;tr valign=&quot;TOP&quot;&gt;
		&lt;td width=&quot;50%&quot;&gt;{}&lt;/td&gt;
		&lt;td width=&quot;50%&quot;&gt;Creates text for an element&lt;/td&gt;
	&lt;/tr&gt;
&lt;tr valign=&quot;TOP&quot;&gt;
		&lt;td width=&quot;50%&quot;&gt;$&lt;/td&gt;
		&lt;td width=&quot;50%&quot;&gt;Incremental number (starts with 1)&lt;/td&gt;
	&lt;/tr&gt;
&lt;tr valign=&quot;TOP&quot;&gt;
		&lt;td width=&quot;50%&quot;&gt;$$&lt;/td&gt;
		&lt;td width=&quot;50%&quot;&gt;Incremental number with padding(starts with 01)&lt;/td&gt;
	&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
In this ZenCoding, you only need to
remember the selector and its usage, Based on that you can make “n”
number of combinations while designing HTML based on your
requirement. It saves the development time a lot.&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
Now, I am going to explain few
combinations which helps you to gear up on usage of ZenCoding in your
daily base development environment.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;ZenCoding implementation, you have to type the expression and then by clicking on &quot;TAB&quot; then automatically that expression would be changed to HTML format.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
The below provided examples each one contains three sections in a comments.&lt;br /&gt;
&lt;br /&gt;
1. &lt;b&gt;Requirement:&lt;/b&gt; It indicates the requirement to make a ZenCoding expression&lt;br /&gt;
2. &lt;b&gt;Expression:&lt;/b&gt; ZenCoding Expression or syntax to achieve the requirement&lt;br /&gt;
3. &lt;b&gt;Result:&lt;/b&gt; Result of the ZenCoding Expression &lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in; text-align: justify;&quot;&gt;
&lt;b&gt;Scenario 1:&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;
&lt;!-- Requirement: Generate div with Id and class --&gt;
&lt;!-- Expression: div#header.headerClass --&gt;
&lt;!-- Result --&gt;
&lt;div class=&quot;headerClass&quot; id=&quot;header&quot;&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;b&gt;Scenario 2:&lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;
&lt;!-- Requirement: Generate  list of 5 input text controls in a div --&gt;
&lt;!-- Expression: div#section.SectionClass&gt;input[type=&quot;text&quot;]*5 --&gt;
&lt;!-- Result --&gt;
&lt;div class=&quot;SectionClass&quot; id=&quot;section&quot;&gt;
&lt;input type=&quot;text&quot; value=&quot;&quot; /&gt;
	&lt;input type=&quot;text&quot; value=&quot;&quot; /&gt;
	&lt;input type=&quot;text&quot; value=&quot;&quot; /&gt;
	&lt;input type=&quot;text&quot; value=&quot;&quot; /&gt;
	&lt;input type=&quot;text&quot; value=&quot;&quot; /&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;b&gt; Scenario 3: &lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;&lt;!-- Requirement: Generate  list of 5 input text controls with 
                  successive Id number and value in a div --&gt;
&lt;!-- Expression: 
div#section.section&gt;input[type=&quot;text&quot; id=&quot;txt-$$&quot; value=&quot;val-$$&quot;]*5
      --&gt;
&lt;!-- Result --&gt;
&lt;div class=&quot;section&quot; id=&quot;section&quot;&gt;
&lt;input id=&quot;txt-01&quot; type=&quot;text&quot; value=&quot;val-01&quot; /&gt;
	&lt;input id=&quot;txt-02&quot; type=&quot;text&quot; value=&quot;val-02&quot; /&gt;
	&lt;input id=&quot;txt-03&quot; type=&quot;text&quot; value=&quot;val-03&quot; /&gt;
	&lt;input id=&quot;txt-04&quot; type=&quot;text&quot; value=&quot;val-04&quot; /&gt;
	&lt;input id=&quot;txt-05&quot; type=&quot;text&quot; value=&quot;val-05&quot; /&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;b&gt; Scenario 4: &lt;/b&gt;&lt;br /&gt;
Note: This scenario,I have used $ for anchor id and $$ for 
anchor tag text. you can identify the difference in result.
&lt;br /&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;
&lt;!-- Requirement: Generate div contains unordered list of 4 li 
                  elements with an anchor tag and text
--&gt;
&lt;!-- Expression: 
div#menu.divMenu&gt;ul.menu&gt;li*5&gt;a[id=&quot;click$&quot; href=&quot;#&quot;]{Click here: $$}
--&gt;

&lt;!-- Result --&gt;
&lt;div class=&quot;divMenu&quot; id=&quot;menu&quot;&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; id=&quot;click1&quot;&gt;Click here: 01&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; id=&quot;click2&quot;&gt;Click here: 02&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; id=&quot;click3&quot;&gt;Click here: 03&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; id=&quot;click4&quot;&gt;Click here: 04&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; id=&quot;click5&quot;&gt;Click here: 05&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;b&gt; Scenario 5: &lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;&lt;!-- Requirement: Generate a one div with header and another div with menu links--&gt;
&lt;!-- Expression: 
div#header.divHeader^div#menu.divMenu&gt;ul.menu&gt;li*5&gt;a[id=&quot;click$$&quot; href=&quot;#&quot;]{Click here: $$} 
--&gt;
&lt;!-- Result --&gt;
&lt;div class=&quot;divHeader&quot; id=&quot;header&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;divMenu&quot; id=&quot;menu&quot;&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; id=&quot;click01&quot;&gt;Click here: 01&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; id=&quot;click02&quot;&gt;Click here: 02&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; id=&quot;click03&quot;&gt;Click here: 03&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; id=&quot;click04&quot;&gt;Click here: 04&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; id=&quot;click05&quot;&gt;Click here: 05&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;b&gt; Scenario 6: &lt;/b&gt;&lt;br /&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;&lt;!-- Requirement: Sample template with header,menu, section and footer--&gt;
&lt;!-- Expression: 
div#header.divHeader^(div#menu.divMenu&gt;ul.menu&gt;li*5&gt;a[id=&quot;click$$&quot; href=&quot;#&quot;]{Click here: $$})
+div#section{Section Items}+div#footer{footer Display}
--&gt;
&lt;!-- Result --&gt;

&lt;div class=&quot;divHeader&quot; id=&quot;header&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;divMenu&quot; id=&quot;menu&quot;&gt;
&lt;ul class=&quot;menu&quot;&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; id=&quot;click01&quot;&gt;Click here: 01&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; id=&quot;click02&quot;&gt;Click here: 02&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; id=&quot;click03&quot;&gt;Click here: 03&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; id=&quot;click04&quot;&gt;Click here: 04&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot; id=&quot;click05&quot;&gt;Click here: 05&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div id=&quot;section&quot;&gt;
Section Items&lt;/div&gt;
&lt;div id=&quot;footer&quot;&gt;
footer Display&lt;/div&gt;
&lt;/pre&gt;
&lt;h3&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;Lorem Pixel Generator&lt;/b&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;As part of ZenCoding, Lorem Pixel Generator is also one of the feature provided in Web Essentials. It helps to generate sample or random images from &lt;a href=&quot;http://lorempixel.com/&quot; target=&quot;_blank&quot;&gt;lorempixel&lt;/a&gt; site.&lt;/span&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;b&gt;It generates image tag by typing expression and then hitting &quot;TAB&quot; button.&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;&lt;!--Requirement: Generate image tag --&gt;
&lt;!-- Expression: pix --&gt;
&lt;!-- Result: 
&lt;img src=&quot;http://lorempixel.com/30/30/&quot; alt=&quot;&quot; /&gt; --&gt;
&lt;/pre&gt;
The default image tag will be generated with height and width of 30 pixels.

you can change the height and width of the image as well. The code pattern is as follows.
&lt;br /&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;&lt;!--Requirement: Generate image tag with height of 250 and width of 300 --&gt;
&lt;!-- Expression: pix-250X300 --&gt;
&lt;!-- Result: 
&lt;img src=&quot;http://lorempixel.com/250/300/&quot; alt=&quot;&quot; /&gt; --&gt;
&lt;/pre&gt;
you can display the random images of animals, cats and nature etc from lorempixel site.
&lt;br /&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;&lt;!-- Requirement: Display images of nature type --&gt;
&lt;!-- Expression: pix-250X300-nature --&gt;
&lt;!-- Result 
&lt;img src=&quot;http://lorempixel.com/250/300/nature/7/&quot; alt=&quot;&quot; /&gt; --&gt;
&lt;/pre&gt;
The other expressions, you can use in Lorem Pixel is as follows;
&lt;br /&gt;
&lt;pre class=&quot;HTML&quot; name=&quot;code&quot;&gt;&lt;!-- Requirement: To display images with height, width, category 
of images with watermark text
&lt;!-- Expression: pix-350X400-nature-ramchand --&gt; 
&lt;!-- Result 
 &lt;img src=&quot;http://lorempixel.com/250/300/nature/3/Ramchand/&quot;
 alt=&quot;&quot; /&gt; --&gt;

&lt;!--Requirement: To display images in a grey color --&gt;
&lt;!--Expression: pix-g-250X300-nature-Ramchand --&gt; 
&lt;!-- Result 
 &lt;img src=&quot;http://lorempixel.com/g/250/300/nature/7/Ramchand/&quot; 
alt=&quot;&quot; /&gt;
--&gt;
&lt;/pre&gt;
&lt;h3&gt;
&lt;span style=&quot;color: #B56108;&quot;&gt;Conclusion:&amp;nbsp;&lt;/span&gt;&lt;/h3&gt;&lt;br/&gt;
&lt;span style=&quot;color: #783f04;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;
 &amp;nbsp;&amp;nbsp; I hope you get some brief idea on ZenCoding and Lorem Pixel generator for those are part of html features in Web Essentials.Please provide your valuable suggestions and comments if any.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3&gt;
&lt;span style=&quot;color: #783f04;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;color: #B56108;&quot;&gt;References:&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;br/&gt;
&lt;span style=&quot;color: #783f04;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;1. &lt;a href=&quot;http://vswebessentials.com/features/html&quot; target=&quot;_blank&quot;&gt;Web Essentials html Features&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #783f04;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;2. &lt;a href=&quot;http://www.johnpapa.net/zen-coding-in-visual-studio-2012/&quot; target=&quot;_blank&quot;&gt;Zen Coding Techniques by John Papa&lt;/a&gt;&amp;nbsp;&lt;/span&gt; &lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/4732615359723305686/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2014/09/zencoding-lorem-pixel-generator-vs-net-2013.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/4732615359723305686'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/4732615359723305686'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2014/09/zencoding-lorem-pixel-generator-vs-net-2013.html' title='ZenCoding and Lorem pixel generator in .NET'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4172426161974972492.post-6045213069191600934</id><published>2014-09-09T00:43:00.000+05:30</published><updated>2014-11-30T20:06:25.831+05:30</updated><title type='text'></title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;OTHERS&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;color: #cc6611; text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: #cc6611;&quot;&gt;
&lt;a href=&quot;http://ramchandr.blogspot.com/2014/09/less-css-in-net_7.html&quot; target=&quot;_blank&quot;&gt;
&lt;b&gt;LESS CSS in .NET&lt;/b&gt;
&lt;/a&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: #cc6611;&quot;&gt;
&lt;a href=&quot;http://ramchandr.blogspot.com/2014/09/zencoding-lorem-pixel-generator-vs-net-2013.html&quot; target=&quot;_blank&quot;&gt;
&lt;b&gt;ZenCoding and Lorem Pixel Generator in Visual Studio 2013&lt;/b&gt;
&lt;/a&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: #cc6611;&quot;&gt;
&lt;a href=&quot;http://ramchandr.blogspot.com/2014/09/visual-studio-key-notes-and-features.html&quot; target=&quot;_blank&quot;&gt;
&lt;b&gt;Visual Studio Key Notes&lt;/b&gt;
&lt;/a&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: #cc6611;&quot;&gt;
&lt;a href=&quot;http://ramchandr.blogspot.com/2014/11/literals-and-seperators-in-csharp-6.html&quot; target=&quot;_blank&quot;&gt;
&lt;b&gt;Literals and Separators in C# 6.0&lt;/b&gt;
&lt;/a&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: #cc6611;&quot;&gt;
&lt;a href=&quot;http://ramchandr.blogspot.com/2014/11/exception-filters-in-csharp-6.html&quot; target=&quot;_blank&quot;&gt;
&lt;b&gt;Exception Filters in C# 6.0&lt;/b&gt;
&lt;/a&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;background-color: white; color: #cc6611;&quot;&gt;
&lt;a href=&quot;http://ramchandr.blogspot.com/2014/11/conditional-access-in-csharp-6.html&quot; target=&quot;_blank&quot;&gt;
&lt;b&gt;Conditional Access in C# 6.0&lt;/b&gt;
&lt;/a&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/6045213069191600934/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2014/09/all-other-tech-info.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/6045213069191600934'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/6045213069191600934'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2014/09/all-other-tech-info.html' title=''/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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-4172426161974972492.post-4824057978033212681</id><published>2014-09-09T00:02:00.001+05:30</published><updated>2014-11-30T20:17:58.445+05:30</updated><title type='text'></title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;color: #b45f06;&quot;&gt;MVC &lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;color: #cc6611; text-align: left;&quot;&gt;
&lt;li&gt;
&lt;a href=&quot;http://ramchandr.blogspot.com/2014/09/action-result-return-type-in-mvc-50.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Action Result in MVC&lt;/b&gt;
&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&quot;http://ramchandr.blogspot.com/2014/09/view-result-return-type-in-mvc-50.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;ViewResult Return Type in MVC&lt;/b&gt;
&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&quot;http://ramchandr.blogspot.com/2014/09/partial-view-result-sample-web-app-in-mvc.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;PartialView Result Return Type in MVC with sample application&lt;/b&gt;
&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&quot;http://ramchandr.blogspot.com/2014/09/prevent-partial-view-to-access-directly-in-mvc.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Prevent Partial view to access directly in MVC&lt;/b&gt;
&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&quot;http://ramchandr.blogspot.com/2014/10/jsonresult-type-in-mvc.html&quot; target=&quot;_blank&quot;&gt;
&lt;b&gt;JsonResult in MVC&lt;/b&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&quot;http://ramchandr.blogspot.com/2014/10/contentresult-in-mvc.html&quot; target=&quot;_blank&quot;&gt;
&lt;b&gt;ContentResult in MVC&lt;/b&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&quot;http://ramchandr.blogspot.in/2014/11/multilanguage-sample-mvc-application.html&quot; target=&quot;_blank&quot;&gt;
&lt;b&gt;Multi Language MVC application with Customized JS bundles&lt;/b&gt;
&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href=&quot;http://ramchandr.blogspot.com/2014/11/skype-status-display-for-user-in-mvc.html&quot; target=&quot;_blank&quot;&gt;
&lt;b&gt;Skype Status Display For an User in MVC&lt;/b&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/4824057978033212681/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2014/09/all-about-mvc.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/4824057978033212681'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/4824057978033212681'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2014/09/all-about-mvc.html' title=''/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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-4172426161974972492.post-3331010376634198811</id><published>2014-09-07T21:45:00.002+05:30</published><updated>2014-09-08T10:40:36.277+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term=".NET"/><category scheme="http://www.blogger.com/atom/ns#" term="LESS"/><category scheme="http://www.blogger.com/atom/ns#" term="MVC 5.0"/><category scheme="http://www.blogger.com/atom/ns#" term="Web Essentials"/><title type='text'>LESS CSS in .NET</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
Less css is kind of dynamic stylesheet language which is very helpful while designing css for any templates or forms.&lt;br /&gt;
&lt;br /&gt;
As you are designing&amp;nbsp; any template, For example, the color which you are using is same as header, body or font etc. &lt;br /&gt;
&lt;br /&gt;
So, Normal css would look like as follows.&lt;br /&gt;
&lt;pre class=&quot;CSS&quot; name=&quot;code&quot;&gt;body {
&amp;nbsp; color: #808080;
}
header {
&amp;nbsp; color: #808080;
}
#TestId {
&amp;nbsp; color: #808080;
}
&lt;/pre&gt;
For the above example, if you need to change the color then need to update the color manually. But if you are using the LESS css then it would be very easy to update the color in a dynamic way.&lt;br /&gt;
&lt;br /&gt;
Note: LESS format file is the part of Web essentials in Visual studio. you can get the web essentials from the link &lt;a href=&quot;http://vswebessentials.com/&quot; target=&quot;_blank&quot;&gt;Web Essentials&lt;/a&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, I am going to explain how to add LESS file and its implementation process in sample MVC application.&lt;br /&gt;
&lt;br /&gt;
Add a new item to the Content folder then select LESS Style Sheet, mention the name as Demo.less then the output screen would look like below.&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/AVvXsEiTsItVUtYQkLEfyuvwxFlk6YiiqEwlYHGvS8-e4XSjkVjj4b6XBAlXt0MNKFy3N6URLE8peQ9YIQldq17-PhUXcFpHyIqDsqen0lhOX72nO5sqvS6qL5tBWEGGmPk4aVtEn8T5w10qLxA/s1600/less-css-add.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTsItVUtYQkLEfyuvwxFlk6YiiqEwlYHGvS8-e4XSjkVjj4b6XBAlXt0MNKFy3N6URLE8peQ9YIQldq17-PhUXcFpHyIqDsqen0lhOX72nO5sqvS6qL5tBWEGGmPk4aVtEn8T5w10qLxA/s1600/less-css-add.png&quot; height=&quot;240&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
you can declare an variable named as for example @TemplateColor&amp;nbsp; and assign the color value to that variable.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSS&quot; name=&quot;code&quot;&gt;@TemplateColor: #808080;
&lt;/pre&gt;
&lt;br /&gt;
After that , as you mentioned the above normal css and replace the color value with the variable like the below.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSS&quot; name=&quot;code&quot;&gt;
body {
&amp;nbsp;&amp;nbsp;&amp;nbsp; color: @TemplateColor;
}

header {
&amp;nbsp;&amp;nbsp;&amp;nbsp; color: @TemplateColor;
}

#TestId {
&amp;nbsp;&amp;nbsp;&amp;nbsp; color: @TemplateColor;
}
&lt;/pre&gt;

So, Now the complete sample LESS file is ready with the below format.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;CSS&quot; name=&quot;code&quot;&gt;@TemplateColor: #808080;

body {
&amp;nbsp;&amp;nbsp;&amp;nbsp; color: @TemplateColor;
}

header {
&amp;nbsp;&amp;nbsp;&amp;nbsp; color: @TemplateColor;
}

#TestId {
&amp;nbsp;&amp;nbsp;&amp;nbsp; color: @TemplateColor;
}
&lt;/pre&gt;
After that, just save the file by pressing (Ctrl+S) then automatically the css and min.css will be ready in your solution.&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzcGTWSXqox-OsFyIomVGRb3XUupgma8mm6Bv0p5fKhUvLMIscnPg3lsS0Z-7yDrNxRkc3y8AfessStSW2P2lFhdn4oHozUQ0gRtlXX_k4JRxkf3WVBixMxaU7Rl_2R_ivJ08Vax7EmXM/s1600/less-css.png&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzcGTWSXqox-OsFyIomVGRb3XUupgma8mm6Bv0p5fKhUvLMIscnPg3lsS0Z-7yDrNxRkc3y8AfessStSW2P2lFhdn4oHozUQ0gRtlXX_k4JRxkf3WVBixMxaU7Rl_2R_ivJ08Vax7EmXM/s1600/less-css.png&quot; height=&quot;240&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Its very easy to change from one color to another by just updating the color for @TemplateColor variable instead of whole css. 

&lt;br /&gt;
&lt;span style=&quot;color: #b45f06;&quot;&gt;&lt;b&gt;Conclusion:&lt;/b&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
I hope this article gives you brief idea on LESS css with sample example.Please provide your valuable suggestions and comments if any.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ramchandr.blogspot.com/feeds/3331010376634198811/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://ramchandr.blogspot.com/2014/09/less-css-in-net_7.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/3331010376634198811'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4172426161974972492/posts/default/3331010376634198811'/><link rel='alternate' type='text/html' href='http://ramchandr.blogspot.com/2014/09/less-css-in-net_7.html' title='LESS CSS in .NET'/><author><name>Ramchand</name><uri>http://www.blogger.com/profile/13034544926598247649</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/AVvXsEiTsItVUtYQkLEfyuvwxFlk6YiiqEwlYHGvS8-e4XSjkVjj4b6XBAlXt0MNKFy3N6URLE8peQ9YIQldq17-PhUXcFpHyIqDsqen0lhOX72nO5sqvS6qL5tBWEGGmPk4aVtEn8T5w10qLxA/s72-c/less-css-add.png" height="72" width="72"/><thr:total>1</thr:total></entry></feed>