tag:blogger.com,1999:blog-51508474775156769482024-02-06T19:19:25.802-08:00Developer BlogC#, C++, VB, WPF, WCF, WF, MVC, ASP.NET, ORACLE, SQL SERVER, SYBASE, Visual Studio Add-ins,Windows Service,Web Service, Winforms, Windows Phone, XSLT, JQuery, CSS, JSon, LINQ, EntityFramework, Performance, Problems & Solutions, Batch File, CMD, Data structure and Algorithm, Automation, SGML, JavascriptDotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.comBlogger198125tag:blogger.com,1999:blog-5150847477515676948.post-62336430315744070182016-06-11T07:23:00.000-07:002016-06-11T07:23:39.480-07:00Sample application for Download and View PDF files in ASP.NET MVC<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif; font-size: 12px; line-height: 21.6px;"><br /></span><span style="background-color: white; color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif; font-size: 12px; line-height: 21.6px;">In this post we are going to see how to view or download PDF files in ASP.NET MVC, Normally in applications we have reports and files to be viewed in PDF format, sometimes we need to download the files, Now we are going to see various ways of viewing a PDF file and downloading option in MVC.</span><br />
<span style="background-color: white; color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif; font-size: 12px; line-height: 21.6px;"><br /></span><span style="background-color: white; color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif; font-size: 12px; line-height: 21.6px;">In ASP.NET MVC we have action result which is used to server the file content to the client browser, FilePathResult is used to display the content of the PDF file in the browser.</span><br />
<span style="background-color: white; color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif; font-size: 12px; line-height: 21.6px;"><br /></span><span style="background-color: white; color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif; font-size: 12px; line-height: 21.6px;">Steps to do:</span><br />
<span style="background-color: white; color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif; font-size: 12px; line-height: 21.6px;">1. Create a MVC Project </span><br />
<span style="background-color: white; color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif; font-size: 12px; line-height: 21.6px;">2. Create a Folder PdfFiles</span><br />
<span style="background-color: white; color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif; font-size: 12px; line-height: 21.6px;">3. Place your PDF files</span><br />
<span style="background-color: white; color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif; font-size: 12px; line-height: 21.6px;">4. Start writing your Controller logic.</span><br />
<span style="background-color: white; color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif; font-size: 12px; line-height: 21.6px;"><br /></span><span style="background-color: white;"><span style="color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;">Here for View , we will do three different ways one with passing File path, another one with passing File Content, another one is embedding as inline PDF using Ajax.</span></span></span><br />
<span style="background-color: white;"><span style="color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><br /></span></span></span><span style="background-color: white;"><span style="font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><b>Controller Logic:</b></span></span></span><br />
<span style="background-color: white;"><span style="font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><b><br /></b></span></span></span><span style="background-color: white;"><span style="color: red; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><b>HomeController</b></span></span></span><br />
<span style="background-color: white;"><span style="color: red; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><b><br /></b></span></span></span>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> System;</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> System.Collections.Generic;</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> System.IO;</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> System.Linq;</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> System.Web;</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> System.Web.Mvc;</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> ViewPDF.Models;</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">namespace</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> ViewPDF.Controllers</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">{</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">public</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">class</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">HomeController</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> : </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">Controller</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> {</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">public</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">ActionResult</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> Index()</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> {</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">FileInfo</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> []info = </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">new</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">DirectoryInfo</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">(Server.MapPath(</span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"/PdfFiles"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">)).GetFiles();</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">return</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> View(info.ToList());</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> }</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">public</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">ActionResult</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> About()</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> {</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> ViewBag.Message = </span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"Your application description page."</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">;</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">return</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> View();</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> }</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">public</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">ActionResult</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> Contact()</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> {</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> ViewBag.Message = </span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"Your contact page."</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">;</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">return</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> View();</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> }</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">public</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">FileResult</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> ViewPDF(</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">string</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> name)</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> {</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">return</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> File(name, </span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"application/pdf"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">);</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> }</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">public</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">FileResult</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> DownloadPDF(</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">string</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> name)</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> {</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">byte</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">[] pdfByte = FileContent(name);</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">return</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> File(pdfByte, </span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"application/pdf"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">, name.Substring(name.LastIndexOf(</span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"\\"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">)+1));</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> }</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">public</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">FileResult</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> PDFDisplay(</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">string</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> name)</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> { </span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">byte</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">[] pdfByte = FileContent(name);</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">return</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> File(pdfByte, </span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"application/pdf"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">);</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> }</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">public</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">PartialViewResult</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> PDFInlineView(</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">string</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> name)</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> { </span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">PDFModel</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> model = </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">new</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">PDFModel</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">() {FilePath = name };</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">return</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> PartialView(</span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"PDFView"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">,model);</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> }</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">private</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">byte</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">[] FileContent(</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">string</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> path)</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> { </span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">FileStream</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> stream = </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">null</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">; </span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">try</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> {</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> stream = System.IO.</span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">File</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">.OpenRead(path);</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">byte</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">[] bytes = </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">new</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">byte</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">[stream.Length];</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> stream.Read(bytes, 0, </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">Convert</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">.ToInt32(stream.Length));</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">return</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> bytes;</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> }</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">finally</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> {</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">if</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> (stream != </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">null</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">)</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> {</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> stream.Close();</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> stream.Dispose();</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> }</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> }</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> }</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> }</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">}</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<span style="background-color: white;"><span style="color: red; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><b>create a model class to pass the model to async operation, we need a virtual path to process in async operation</b></span></span></span><br />
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">public</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">class</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">PDFModel</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> {</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">private</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">string</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> _virtualFilepath;</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">public</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">string</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> FilePath {</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">set</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> {</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> _virtualFilepath= </span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"../PdfFiles/"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> + </span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> value</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">.Substring(</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">value</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">.LastIndexOf(</span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"\\"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">) + 1 );</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> }</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">get</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> { </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">return</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> _virtualFilepath; }</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> }</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> }</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<span style="background-color: white;"><span style="font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><b><br /></b></span></span></span><span style="background-color: white;"><span style="font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><b>HTML Logic:</b></span></span></span><br />
<span style="background-color: white;"><span style="color: red; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><b><br /></b></span></span></span><span style="background-color: white;"><span style="color: red; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><b>index.cshtml</b></span></span></span><br />
<span style="background-color: white;"><span style="color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><br /></span></span></span>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 0); font-family: "consolas"; font-size: 9.5pt;">@</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> System.IO</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 0); font-family: "consolas"; font-size: 9.5pt;">@{</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> ViewBag.Title = </span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"Home Page"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">;</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 0); font-family: "consolas"; font-size: 9.5pt;">}</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 0); font-family: "consolas"; font-size: 9.5pt;">@model </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">IEnumerable</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">FileInfo</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">div</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">class</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="panel"></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">table</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">class</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="table table-condensed"></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">thead</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">tr</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">FileName</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">View</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">Download</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">View2</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">Inline view</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">tr</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">thead</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">tbody</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 0); font-family: "consolas"; font-size: 9.5pt;">@</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">foreach</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> (</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">var</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> item </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">in</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> Model)</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> {</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">tr</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">class</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">=""></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">class</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="col-lg-1"></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> <</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">label</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 0); font-family: "consolas"; font-size: 9.5pt;">@</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">item.Name </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">span</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 0); font-family: "consolas"; font-size: 9.5pt;">@</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">item.Length</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">span</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">label</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> </</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">class</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="col-lg-1"></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> <</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">button</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">class</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="btn btn-info btn-sm" </span><span style="background: rgb(255, 255, 0); font-family: "consolas"; font-size: 9.5pt;">@</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">Html.ActionLink(</span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"View"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">, </span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"ViewPDF"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">, </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">new</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> { name = item.FullName })</span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> </</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">button</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> </</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">class</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="col-lg-1"></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> <</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">button</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">class</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="btn btn-info btn sm"></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 0); font-family: "consolas"; font-size: 9.5pt;">@</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">Html.ActionLink(</span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"Download"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">, </span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"DownloadPDF"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">, </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">new</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> { name = item.FullName })</span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> </</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">button</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> </</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">class</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="col-lg-1"></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> <</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">button</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">class</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="btn btn-info btn-sm"> </span><span style="background: rgb(255, 255, 0); font-family: "consolas"; font-size: 9.5pt;">@</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">Html.ActionLink(</span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"View2"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">, </span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"PDFDisplay"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">, </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">new</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> { name = item.FullName })</span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> </</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">button</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> </</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">class</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="col-lg-1"></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> <</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">button</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">class</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="btn btn-info btn-sm"> </span><span style="background: rgb(255, 255, 0); font-family: "consolas"; font-size: 9.5pt;">@</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">Ajax.ActionLink(</span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"InlineView"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">, </span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"PDFInlineView"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">, </span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> new</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> { name = item.FullName }, </span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> new</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">AjaxOptions</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> { UpdateTargetId = </span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">pdf</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">Inline</span><span style="background: rgb(255, 255, 255); color: #a31515; font-family: "consolas"; font-size: 9.5pt;">"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> })</span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> </</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">button</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"> </</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">td</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">tr</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> }</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">tbody</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">ul</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">div</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">id</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="pdf</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">Inline</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">"></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">div</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">div</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p><br /></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p><br /></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p><b><span style="color: red;"><br /></span></b></o:p></span></div>
<span style="background-color: white;"><span style="color: red; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><b>pdfview.cshtml</b></span></span></span><br />
<span style="background-color: white;"><span style="color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><br /></span></span></span>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 0); font-family: "consolas"; font-size: 9.5pt;">@model </span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">ViewPDF.Models.</span><span style="background: rgb(255, 255, 255); color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">PDFModel</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">h4</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">PDF inline View....</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">h4</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">object</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">style</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="</span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">height</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">:</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">500px</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">;</span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">width</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">:</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">800px"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">data</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="</span><span style="background: rgb(255, 255, 0); font-family: "consolas"; font-size: 9.5pt;">@</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">Model.FilePath</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">type</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="application/pdf"></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">p</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">It appears that you don't have Adobe Reader or PDF support in this web browser. </span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">a</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">href</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="</span><span style="background: rgb(255, 255, 0); font-family: "consolas"; font-size: 9.5pt;">@</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">Model.FilePath</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">"></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">Click here to download the PDF</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">a</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">. Or </span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">a</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">href</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="http://get.adobe.com/reader/"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">target</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="_blank"></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">click here to install Adobe Reader</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">a</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">.</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">p</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">embed</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">src</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="</span><span style="background: rgb(255, 255, 0); font-family: "consolas"; font-size: 9.5pt;">@</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;">Model.FilePath</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: red; font-family: "consolas"; font-size: 9.5pt;">type</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">="application/pdf"</span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"> </span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">/></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;"></</span><span style="background: rgb(255, 255, 255); color: maroon; font-family: "consolas"; font-size: 9.5pt;">object</span><span style="background: rgb(255, 255, 255); color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="background: rgb(255, 255, 255); font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<span style="background-color: white;"><span style="color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><br /></span></span></span><span style="background-color: white;"><span style="color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><b><br /></b></span></span></span><span style="background-color: white;"><span style="color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><b><br /></b></span></span></span><span style="background-color: white;"><span style="color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><b><br /></b></span></span></span><span style="background-color: white;"><span style="color: red; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><b>Output:</b></span></span></span><br />
<span style="background-color: white;"><span style="color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"> When you click the View button it will display the PDF file in the browser.</span></span></span><br />
<span style="background-color: white;"><span style="color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><br /></span></span></span>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgD8YrdLUV5v8hAr0LhQtpXIxRpjOKtI_A4XOaC0Tlv10hO5qHV_C6jPD4YtQKa8_xaq7E6UCxjDCzG0hXt5XVsde0haZZc2MPkYJl1htJBo7KcxQ6T2OByNx2yzBR5NNhZtIEU0o22oywD/s1600/index.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="172" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgD8YrdLUV5v8hAr0LhQtpXIxRpjOKtI_A4XOaC0Tlv10hO5qHV_C6jPD4YtQKa8_xaq7E6UCxjDCzG0hXt5XVsde0haZZc2MPkYJl1htJBo7KcxQ6T2OByNx2yzBR5NNhZtIEU0o22oywD/s400/index.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="background-color: white; color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif; font-size: 12px; line-height: 21.6px; text-align: left;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="background-color: white; color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif; font-size: 12px; line-height: 21.6px; text-align: left;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<span style="background-color: white; color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif; font-size: 12px; line-height: 21.6px; text-align: left;">When you click the download button it will download the PDF files</span></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZGNk-DrY3fwCzKDrtNHW40SqPhkpjPY-jCFniwjMo3P1AhBrl4SSjI-VJUdOSxbLk7w-8wf3pKrAIg0HR94INKvAtPUDNEJPxQkWiLfoYq7NPv_OzjK9R-SIZG_Sriu3hRgMbEzzHBJjl/s1600/Download.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="223" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZGNk-DrY3fwCzKDrtNHW40SqPhkpjPY-jCFniwjMo3P1AhBrl4SSjI-VJUdOSxbLk7w-8wf3pKrAIg0HR94INKvAtPUDNEJPxQkWiLfoYq7NPv_OzjK9R-SIZG_Sriu3hRgMbEzzHBJjl/s400/Download.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<b><span style="color: red;">If the browser doesn't support the inline view it will display a information like below</span></b></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEeQKUzJ23mmuHTacNesi_ZpI_w4eOQY5ATQXhUByHb10V52vmZy5BBfWMYjsa2pEEe9adHNyn-KT2laTJJN9C1poyi34_JAlJwMXnT8_hdHn2UWngflLWUiJ3cDpsW5PsdEPm_iQ2SfnN/s1600/inline.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="88" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEeQKUzJ23mmuHTacNesi_ZpI_w4eOQY5ATQXhUByHb10V52vmZy5BBfWMYjsa2pEEe9adHNyn-KT2laTJJN9C1poyi34_JAlJwMXnT8_hdHn2UWngflLWUiJ3cDpsW5PsdEPm_iQ2SfnN/s400/inline.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<b><span style="color: red;">Ajax - Async operation of Viewing PDF as Inline</span></b></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7TDTFHTgX7d_RjJAlKAdRh95wbsYNnYq0CUZAOGwV1IRlDE3JBAu-3GcgeWDOJYqoYftfQSWrq3LR35IReTqFTXH1uezRLB-axhkxjLt5HD94zQQxMDV3u3eIn5ZX5JDhS3fUKT_FwX1u/s1600/inlineView.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="283" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7TDTFHTgX7d_RjJAlKAdRh95wbsYNnYq0CUZAOGwV1IRlDE3JBAu-3GcgeWDOJYqoYftfQSWrq3LR35IReTqFTXH1uezRLB-axhkxjLt5HD94zQQxMDV3u3eIn5ZX5JDhS3fUKT_FwX1u/s400/inlineView.png" width="400" /></a></div>
<span style="background-color: white;"><span style="color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><br /></span></span></span><span style="background-color: white;"><span style="color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="font-size: 12px; line-height: 21.6px;"><br /></span></span></span><span style="color: #5b606b; font-family: "arial" , "tahoma" , "verdana" , "helvetica" , sans-serif;"><span style="background-color: white; font-size: 12px; line-height: 21.6px;">From this post you can learn how to create a application to View and Download PDF files in ASP.NET MVC</span></span></div>
DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com1tag:blogger.com,1999:blog-5150847477515676948.post-2546649766644051402016-06-04T02:27:00.002-07:002016-06-04T02:27:34.498-07:00UnHandled Microsoft .Net Framework Exception occured in visual studio devenv.exe in design mode forces visual studio to close (Microsoft Bug)<div dir="ltr" style="text-align: left;" trbidi="on">
In this post we are going to see a error which forces the development environment crashes and close because of user code and makes the developers to stand in a some crucial situation.<br />
<br />
<br />
<br />
<b><span style="color: red;">Click Here to see bug info</span></b><br />
<a href="https://connect.microsoft.com/VisualStudio/feedback/details/2769909/an-unhandled-microsoft-net-framework-exception-occured-in-devenv-exe-in-design-mode-of-winforms-forces-the-visual-studio-to-close">https://connect.microsoft.com/VisualStudio/feedback/details/2769909/an-unhandled-microsoft-net-framework-exception-occured-in-devenv-exe-in-design-mode-of-winforms-forces-the-visual-studio-to-close</a><br />
<br />
<br />
<br />
<div>
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMMY65N8XQsFpWFGQ098JNm0GZcvMbArfHygQPF_M1pKvFciK4_QFE8KnIESMubIgdq5F59rEjmnW0ZWDkDYmIYmCTBJS5wDtnTv3o2gRpZNHVn5YBOiGoqF03epuTB1MzDOsZE4qqSsYZ/s1600/m1.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMMY65N8XQsFpWFGQ098JNm0GZcvMbArfHygQPF_M1pKvFciK4_QFE8KnIESMubIgdq5F59rEjmnW0ZWDkDYmIYmCTBJS5wDtnTv3o2gRpZNHVn5YBOiGoqF03epuTB1MzDOsZE4qqSsYZ/s640/m1.png" width="640" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
Normally Development environment DevEnv.exe is used to develop the code which needs to run in windows Machines , ya it is Visual studio exe. The purpose of this Development environment is used to give a users a sophisticated way for development like Giving intellisense, showing performance reports, Exeception handling like capturing the errors , notifying to users in run time as well as in design time. In some cases it is fails Let we see the cases where it is failed<br />
<br />
<br />
<b><span style="color: red;">Example Design time errors capture in Component in Visual studio while development</span></b><br />
<b><span style="color: red;"><br /></span></b>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBvbNFN-962-hensuVzJMpRVbM1nD9X_Ojog7vL9rjzKm5eYgCgnezcBlGHfgql58BGx-aOhjOIcf_nWNdMgB1bLXAOXLS6Nt5h41f4IBeMwSh463NgMSZfEjEYHgLeOMuRu_52tpJ7n4I/s1600/error1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="55" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBvbNFN-962-hensuVzJMpRVbM1nD9X_Ojog7vL9rjzKm5eYgCgnezcBlGHfgql58BGx-aOhjOIcf_nWNdMgB1bLXAOXLS6Nt5h41f4IBeMwSh463NgMSZfEjEYHgLeOMuRu_52tpJ7n4I/s400/error1.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqUhv3_g52Jq8uXSqBmJKKYwSnyLmPEWAqrF9AyhYIRPWe5kyxf6nfu3rzL7wI4_3bbt39sBqnJEF6zRBw1_b5XXK9cCPfZBHi3GeLSOKUnHGFR95RPmUcMoxgX0nTp8E9zoBIpOAj9bDO/s1600/error2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="53" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqUhv3_g52Jq8uXSqBmJKKYwSnyLmPEWAqrF9AyhYIRPWe5kyxf6nfu3rzL7wI4_3bbt39sBqnJEF6zRBw1_b5XXK9cCPfZBHi3GeLSOKUnHGFR95RPmUcMoxgX0nTp8E9zoBIpOAj9bDO/s400/error2.png" width="400" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<br />
<br />
Developing a component is usually a good idea in a application, because we can add anything to the control what ever we thought, like wise developing we have to check each and every stage of that control by dragging it in to Form and see the appearance and properties.After finishing the development we will run the Form and see the visual appearance of the control in the UI.<br />
<br />
<br />
<br />
When i am developing a custom control , when i tried to drag and drop and see the UI, it looks good . Then later again i changes something in the Control. Now i got an error says "Not implemented" in the control which is placed on the form, Then i implemented that functionality, Then again the control in the UI, shows another error in design time like Null Reference, again i implemented that steps for the Control, Again it works correctly, so whenever we design a control development environment visual studio will capture the design time errors and show it in Control itself in design.<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKNgOyqOJSRLgLPHeVw7qUIjPoSrOcC_eOoKR4YtXS_xHhbkXCnVwBpAHH-aHQuGeyoVO0Mv1m6Culg851tQAK7DVoYNxiSIyNjU1sh5PHeSuxyAMu5IUmm30ywez5akZgcah7MFkn6knG/s1600/castException.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKNgOyqOJSRLgLPHeVw7qUIjPoSrOcC_eOoKR4YtXS_xHhbkXCnVwBpAHH-aHQuGeyoVO0Mv1m6Culg851tQAK7DVoYNxiSIyNjU1sh5PHeSuxyAMu5IUmm30ywez5akZgcah7MFkn6knG/s1600/castException.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
But in this case Now the Form Freezes and closes after a certain time, again when ever i open the form which have that custom control crashes the DEvEnv.exe. I get wondered how The development can gets crashes for a user code which is in development mode, because devenv.exe will capture the design time errors and show it in UI, because then only developers can develop the thing in that development editor , that is the purpose of that editor.<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGIMqRi9R4Sx4venyJ2qkHcrRMqnNG6rh4msvTldQxbqJ6NE0Q6cXC2jnYe6Qu2WPUNyv3FVDhlfueKJ26gM_3i4ysp9hg7sQbISiUfGrEgBaS-UupfswCNPc_iSTgGafmuywTgZMBXpG8/s1600/vserr0.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="193" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgGIMqRi9R4Sx4venyJ2qkHcrRMqnNG6rh4msvTldQxbqJ6NE0Q6cXC2jnYe6Qu2WPUNyv3FVDhlfueKJ26gM_3i4ysp9hg7sQbISiUfGrEgBaS-UupfswCNPc_iSTgGafmuywTgZMBXpG8/s400/vserr0.png" width="400" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
When the UI freezes , it launches a pop screen with a message that An UnHandles Microsoft .Net Framework Exception occured in devenv.exe in design mode of winforms, Ya here i am using the Winforms as platform.<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZJCKrwe8iSgQCNaUjATw2MEK6uxmk1NbEMJ1rSgRSbf3iCXfaoVx0Y81lVv4_c7xojY7hnNIsLvXa1yc_5A1CFO-Qxtyis_gfj8Oy9qkjmB0O067htqVqC-pIWsgLDD3RhnXun8FnvL3f/s1600/VSerr2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="355" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiZJCKrwe8iSgQCNaUjATw2MEK6uxmk1NbEMJ1rSgRSbf3iCXfaoVx0Y81lVv4_c7xojY7hnNIsLvXa1yc_5A1CFO-Qxtyis_gfj8Oy9qkjmB0O067htqVqC-pIWsgLDD3RhnXun8FnvL3f/s640/VSerr2.png" width="640" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<br />
<br />
I raised a issue to microsoft , i know that my code is buggy, because it is still under development, but how editor gets closed for used buggy code in development, if it is runtime it is acceptable because we are running in CLR, but in design editor should handle everything and shows it to users<br />
<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMMY65N8XQsFpWFGQ098JNm0GZcvMbArfHygQPF_M1pKvFciK4_QFE8KnIESMubIgdq5F59rEjmnW0ZWDkDYmIYmCTBJS5wDtnTv3o2gRpZNHVn5YBOiGoqF03epuTB1MzDOsZE4qqSsYZ/s1600/m1.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMMY65N8XQsFpWFGQ098JNm0GZcvMbArfHygQPF_M1pKvFciK4_QFE8KnIESMubIgdq5F59rEjmnW0ZWDkDYmIYmCTBJS5wDtnTv3o2gRpZNHVn5YBOiGoqF03epuTB1MzDOsZE4qqSsYZ/s640/m1.png" width="640" /></a></div>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
After raising the issue i got a feed back from microsoft like below, it is ideally should not crash visual studio but happening in this case, they are saying cases for unhandling the exceptions.<br />
<b><span style="color: red;"><br /></span></b><b><span style="color: red;"><br /></span></b><b><span style="color: red;"><br /></span></b><b><span style="color: red;">Click Here to see bug info</span></b><br />
<a href="https://connect.microsoft.com/VisualStudio/feedback/details/2769909/an-unhandled-microsoft-net-framework-exception-occured-in-devenv-exe-in-design-mode-of-winforms-forces-the-visual-studio-to-close">https://connect.microsoft.com/VisualStudio/feedback/details/2769909/an-unhandled-microsoft-net-framework-exception-occured-in-devenv-exe-in-design-mode-of-winforms-forces-the-visual-studio-to-close</a><br />
<br />
<br />
<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6i0z-QjlQb5N9grN6KjVz-Epd7jdryzPmMEPdgsVYkD59s3xA88u646zNoQE5kUJ7ma5E8sCH1tZZ9PD_C3Z9VyLCFdu-7nhPe2WmVCKiJv-NRD0aS665ZQBp2eL2lEWqgLqGF95g19uW/s1600/m2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" height="295" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6i0z-QjlQb5N9grN6KjVz-Epd7jdryzPmMEPdgsVYkD59s3xA88u646zNoQE5kUJ7ma5E8sCH1tZZ9PD_C3Z9VyLCFdu-7nhPe2WmVCKiJv-NRD0aS665ZQBp2eL2lEWqgLqGF95g19uW/s640/m2.png" width="640" /></a></div>
<br />
<br />
<br />
<span style="background-color: #fcfcfc; color: #333333; font-family: "segoe ui" , "segoe ui web regular" , "helvetica neue" , "tahoma" , "verdana" , "arial"; font-size: 13px;"><br /></span><span style="background-color: #fcfcfc; color: #333333; font-family: "segoe ui" , "segoe ui web regular" , "helvetica neue" , "tahoma" , "verdana" , "arial"; font-size: 13px;"><br /></span><br />
<span style="background-color: #fcfcfc; color: #333333; font-family: "segoe ui" , "segoe ui web regular" , "helvetica neue" , "tahoma" , "verdana" , "arial"; font-size: 13px;"><br /></span><span style="background-color: #fcfcfc; color: #333333; font-family: "segoe ui" , "segoe ui web regular" , "helvetica neue" , "tahoma" , "verdana" , "arial"; font-size: 13px;"><br /></span><span style="background-color: #fcfcfc; color: #333333; font-family: "segoe ui" , "segoe ui web regular" , "helvetica neue" , "tahoma" , "verdana" , "arial"; font-size: 13px;"><br /></span><br />
<span style="background-color: #fcfcfc; color: #333333; font-family: "segoe ui" , "segoe ui web regular" , "helvetica neue" , "tahoma" , "verdana" , "arial"; font-size: 13px;"><br /></span><span style="background-color: #fcfcfc; color: #333333; font-family: "segoe ui" , "segoe ui web regular" , "helvetica neue" , "tahoma" , "verdana" , "arial"; font-size: 13px;"><br /></span><span style="background-color: #fcfcfc; color: #333333; font-family: "segoe ui" , "segoe ui web regular" , "helvetica neue" , "tahoma" , "verdana" , "arial"; font-size: 13px;">Note : </span><br />
<span style="background-color: #fcfcfc; color: #333333; font-family: "segoe ui" , "segoe ui web regular" , "helvetica neue" , "tahoma" , "verdana" , "arial"; font-size: 13px;">We cant rely on users code to be correct while developing or in design mode, because it is under changes, so devenv.exe should capture the errors in design mode and show in control in design mode, if it is runtime or running the app we can say that we are rely on users code to be correct for stack overflow exceptions .... </span><br />
<span style="background-color: #fcfcfc; color: #333333; font-family: "segoe ui" , "segoe ui web regular" , "helvetica neue" , "tahoma" , "verdana" , "arial"; font-size: 13px;"><br /></span><span style="background-color: #fcfcfc; color: #333333; font-family: "segoe ui" , "segoe ui web regular" , "helvetica neue" , "tahoma" , "verdana" , "arial"; font-size: 13px;"><br /></span><br />
<br />
From this post you can see a Microsoft Bug which persists in visual studio , which is an unhandled exception<br />
<br />
<br />
<br />
<br />
<br /></div>
Anonymoushttp://www.blogger.com/profile/15948000754368140371noreply@blogger.com2tag:blogger.com,1999:blog-5150847477515676948.post-33791632266406405552014-01-10T23:59:00.001-08:002014-01-10T23:59:02.469-08:00Execute Stored Procedure using Entity Framework in ASP.NET MVC<div dir="ltr" style="text-align: left;" trbidi="on">
In this article we are going to see how to execute the stored procedure in entity framework ,In MVC we are going to see the how to add the EF.<br />
<div>
<br /></div>
<div>
Execute the following script in the database to create a stored procedure.</div>
<div>
<br /></div>
<div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10pt;">CREATE</span><span style="font-family: "Courier New"; font-size: 10pt;"> <span style="color: blue;">PROCEDURE</span> FETCHEMPLOYEES<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10pt;">AS<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10pt;">BEGIN<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"> <span style="color: blue;">SELECT</span> <span style="color: grey;">*</span> <span style="color: blue;">FROM</span> EMPTABLE<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10pt;">END<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10pt;">CREATE</span><span style="font-family: "Courier New"; font-size: 10pt;"> <span style="color: blue;">PROCEDURE</span> FETCHEMPLOYEE<span style="color: grey;">(</span>@ID <span style="color: blue;">INT</span><span style="color: grey;">)<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10pt;">AS<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10pt;">BEGIN<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "Courier New"; font-size: 10pt;"> <span style="color: blue;">SELECT</span> <span style="color: grey;">*</span> <span style="color: blue;">FROM</span> EMPTABLE <span style="color: blue;">WHERE</span> ID <span style="color: grey;">=</span> @ID<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "Courier New"; font-size: 10pt;">END<o:p></o:p></span></div>
<div style="background-color: white; background-position: initial initial; background-repeat: initial initial;">
<br /></div>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Create a Empty MVC project, select Razor as Engine. Right click the Models and add new item.Select Data in the left pane and click ADO.NET entity framework model.Give a name as Employee.edmx and press ok.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0Fto49H3xtjhHHaP-oO-Befsvn7piirObTBIUK4C7gUUrqfDa0TtGW60S5GSQdMn779WERK5Vuy2yxdY_zqj-7jVuaKsN51xJ4aDY3mk6YlenUIAebUUk3CKjH7d2vjwVBG4o1QPnOxvL/s1600/EF1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0Fto49H3xtjhHHaP-oO-Befsvn7piirObTBIUK4C7gUUrqfDa0TtGW60S5GSQdMn779WERK5Vuy2yxdY_zqj-7jVuaKsN51xJ4aDY3mk6YlenUIAebUUk3CKjH7d2vjwVBG4o1QPnOxvL/s1600/EF1.png" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Choose the model content as Generate from the database,and click next.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDWaRImXgJYhLMxMRItcVIPWDTsT1SuRL-0uslndHjKg5_JI9xGDqmAbFLqHyfHZKfUHTR9le_w_PS9YzrINeD5lxmWALq4YZ30w9FtA4R-lIPI3VvusxtKjY6C1am8QErIjky-bG85i8L/s1600/EF2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgDWaRImXgJYhLMxMRItcVIPWDTsT1SuRL-0uslndHjKg5_JI9xGDqmAbFLqHyfHZKfUHTR9le_w_PS9YzrINeD5lxmWALq4YZ30w9FtA4R-lIPI3VvusxtKjY6C1am8QErIjky-bG85i8L/s1600/EF2.png" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Now select the New Connection and give the Entities name, then click next. </div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG0mIWG3qkx9VWq7CXNBm3WZ6C9_A6K5pvsYVn7f3HPNEIjFmlu3MUE8OllxsplgsSZCYGZw9-n_Zf7UVGTZ4iyzNt0V6botIwqJQv_gOmjh-7hSMRsqZkd1P121ScvQ5Tp861QaWNWAES/s1600/EF3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgG0mIWG3qkx9VWq7CXNBm3WZ6C9_A6K5pvsYVn7f3HPNEIjFmlu3MUE8OllxsplgsSZCYGZw9-n_Zf7UVGTZ4iyzNt0V6botIwqJQv_gOmjh-7hSMRsqZkd1P121ScvQ5Tp861QaWNWAES/s1600/EF3.png" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Then select the all stored procedure which are need for the project. Give the model name as Employee Model and click Finish.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRNC_Ko4k8VwXDyfWg38iVgLp4kVpD6_wMsEzwgN2P6YHbaLOGqk0_K5-cBAvkqc7pOG3aTy63b8iEeWiattv2OlNNJaRc_Tbi1lXhKXlv-7WAfb3P6amHngiUaOnpWJ9-alad9EzcGBQZ/s1600/EF4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiRNC_Ko4k8VwXDyfWg38iVgLp4kVpD6_wMsEzwgN2P6YHbaLOGqk0_K5-cBAvkqc7pOG3aTy63b8iEeWiattv2OlNNJaRc_Tbi1lXhKXlv-7WAfb3P6amHngiUaOnpWJ9-alad9EzcGBQZ/s1600/EF4.png" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Right click the Employee.edmx and click the model browser to see the following items.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-Aii8FXfcX5dp_5QwdgOJC0zisLo3-EYaEVekqKxnuoHaoX99bay_ojwYEqKNbiXNcigJ8sKdamSdTgLcO9HFSGVKNknPJblOSHpKl19MpWvlB_LQUmifUTniDnm3mD8xpCW4qSMWZN1K/s1600/EF5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-Aii8FXfcX5dp_5QwdgOJC0zisLo3-EYaEVekqKxnuoHaoX99bay_ojwYEqKNbiXNcigJ8sKdamSdTgLcO9HFSGVKNknPJblOSHpKl19MpWvlB_LQUmifUTniDnm3mD8xpCW4qSMWZN1K/s1600/EF5.png" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Expand the EmployeeModel.Store and select the stored procedure and the Tables need to be in project. that need to be added in entities.and click add Function Import to import the stored procedure as Function to the code.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlWukUtLMQA37zRlCNdw9fVAVgf7gjPTj8Jrk3pFtRDvjnCWG9zlIKwF8z_rI2vi5-SI6wKzPRw2vWBEd8Rh56cBUPCJYzT2c14hfdSjTTUsHxKT23DmcofZpBIynkeR1-Xj-CmjWr_7ze/s1600/EF6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlWukUtLMQA37zRlCNdw9fVAVgf7gjPTj8Jrk3pFtRDvjnCWG9zlIKwF8z_rI2vi5-SI6wKzPRw2vWBEd8Rh56cBUPCJYzT2c14hfdSjTTUsHxKT23DmcofZpBIynkeR1-Xj-CmjWr_7ze/s1600/EF6.png" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
In the Add Function Import screen please give the function name as you need and select the return type of that stored procedure based on your requirement. In this project return type is a emptable value , if your are returning a complex type by combining a multiple tables. The entities that are seen in the collection is listed by selected what are selected in the tables in the EmployeeModel.edmx.</div>
<div>
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNJYRMNEmxmEV5N20bRIEYCXr7IMoX3dAbSw10P7GIX_JIBL4K97XTznU3u4EXrvvAFUeDV3Es_JqU3dHtfn6rS7HVMlx8Qv-xBKpia2RFhMqmtXfTPXrZ_KZJZsITSl9Zx-66qw_Cgt7n/s1600/EF7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiNJYRMNEmxmEV5N20bRIEYCXr7IMoX3dAbSw10P7GIX_JIBL4K97XTznU3u4EXrvvAFUeDV3Es_JqU3dHtfn6rS7HVMlx8Qv-xBKpia2RFhMqmtXfTPXrZ_KZJZsITSl9Zx-66qw_Cgt7n/s1600/EF7.png" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Now add a cs file as Empmodel.cs in the Models folder to iterate values from db through stored procedure.</div>
<div>
<br /></div>
<div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Collections.Generic;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Linq;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Data.Objects;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">namespace</span><span style="font-family: Consolas; font-size: 9.5pt;"> EFSample.Models<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">EmpModel</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">EmployeeEntities</span> empdb = <span style="color: blue;">new</span> <span style="color: #2b91af;">EmployeeEntities</span>();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">List</span><<span style="color: #2b91af;">EMPTABLE</span>> GetEmployees()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> empdb.FETCHEMPLOYEES().ToList(); <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">EMPTABLE</span> GetEmployee(<span style="color: blue;">int</span>? id)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> empdb.FETCHEMPLOYEE(id).ToList().Single();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> </span><span style="background-color: white; color: #222222; font-family: Arial, sans-serif; font-size: 10pt;"> </span></div>
</div>
<div>
<br /></div>
<div>
Add the EmployeeController </div>
<div>
<br /></div>
<div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Collections.Generic;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Linq;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web.Mvc;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> EFSample.Models;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">namespace</span><span style="font-family: Consolas; font-size: 9.5pt;"> EFSample.Controllers<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">EmployeeController</span> : <span style="color: #2b91af;">Controller</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> Models.<span style="color: #2b91af;">EmpModel</span> mod = <span style="color: blue;">new</span> Models.<span style="color: #2b91af;">EmpModel</span>();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span> Index()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">List</span><<span style="color: #2b91af;">EMPTABLE</span>> result = mod.GetEmployees();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> View(result);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span> Details(<span style="color: blue;">int</span> id)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">EMPTABLE</span> result = mod.GetEmployee(id);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> View(result);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div style="background-color: white; background-position: initial initial; background-repeat: initial initial;">
<br /></div>
</div>
<div>
<br /></div>
<div>
Add the Index View and Details View.</div>
<div>
<br /></div>
<div>
Index.cshtml</div>
<div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 9.5pt;">@model </span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">IEnumerable</span><span style="font-family: Consolas; font-size: 9.5pt;"><EFSample.Models.<span style="color: #2b91af;">EMPTABLE</span>><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 9.5pt;">@{</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> ViewBag.Title = <span style="color: #a31515;">"Employee Information"</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 9.5pt;">}</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">h2</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;">Employees<span style="color: blue;"></</span><span style="color: maroon;">h2</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">p</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;">@</span>Html.ActionLink(<span style="color: #a31515;">"Create New"</span>, <span style="color: #a31515;">"Create"</span>)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">p</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">table</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">border</span><span style="color: blue;">:2px solid Pink"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">th</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">color</span><span style="color: blue;">:Blue"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;">@</span>Html.DisplayNameFor(model => model.NAME)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">th</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">th</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">color</span><span style="color: blue;">:Blue"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;">@</span>Html.DisplayNameFor(model => model.DEPTID)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">th</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">th</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">color</span><span style="color: blue;">:Blue"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;">@</span>Html.DisplayNameFor(model => model.COUNTRY)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">th</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">th</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">color</span><span style="color: blue;">:Blue"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;">@</span>Html.DisplayNameFor(model => model.MARRIED)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">th</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">th</span><span style="color: blue;">></</span><span style="color: maroon;">th</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 9.5pt;">@</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">foreach</span><span style="font-family: Consolas; font-size: 9.5pt;"> (<span style="color: blue;">var</span> item <span style="color: blue;">in</span> Model) {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;">@</span>Html.DisplayFor(modelItem => item.NAME)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;">@</span>Html.DisplayFor(modelItem => item.DEPTID)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;">@</span>Html.DisplayFor(modelItem => item.COUNTRY)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span><span style="color: blue;">></span> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;">@</span>Html.ActionLink(<span style="color: #a31515;">"Details"</span>, <span style="color: #a31515;">"Details"</span>, <span style="color: blue;">new</span> { id=item.ID }) <o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">table</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<br /></div>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
Details.cshtml</div>
<div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 9.5pt;">@model </span><span style="font-family: Consolas; font-size: 9.5pt;">EFSample.Models.<span style="color: #2b91af;">EMPTABLE</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 9.5pt;">@{</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> ViewBag.Title = <span style="color: #a31515;">"Details"</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial; font-family: Consolas; font-size: 9.5pt;">}</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">h2</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;">Details<span style="color: blue;"></</span><span style="color: maroon;">h2</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">link</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">href</span><span style="color: blue;">="../../Site.css"</span> <span style="color: red;">rel</span><span style="color: blue;">="stylesheet"</span> <span style="color: red;">type</span><span style="color: blue;">="text/css"</span> <span style="color: blue;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">fieldset</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">legend</span><span style="color: blue;">></span>EMPTABLE<span style="color: blue;"></</span><span style="color: maroon;">legend</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">table</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span><span style="color: blue;">></span> <span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;">@</span>Html.DisplayNameFor(model => model.NAME) :<span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">><</span><span style="color: maroon;">td</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">font-weight</span><span style="color: blue;">:bold"></span><span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;">@</span>Html.DisplayFor(model => model.NAME)<span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span><span style="color: blue;">></span> <span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;">@</span>Html.DisplayNameFor(model => model.DEPTID) :<span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">><</span><span style="color: maroon;">td</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">font-weight</span><span style="color: blue;">:bold"></span> <span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;">@</span>Html.DisplayFor(model => model.DEPTID)<span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span><span style="color: blue;">></span> <span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;">@</span>Html.DisplayNameFor(model => model.COUNTRY) :<span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">><</span><span style="color: maroon;">td</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">font-weight</span><span style="color: blue;">:bold"></span><span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;">@</span>Html.DisplayFor(model => model.COUNTRY)<span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">table</span><span style="color: blue;">></span> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">fieldset</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">p</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;">@</span>Html.ActionLink(<span style="color: #a31515;">"Edit"</span>, <span style="color: #a31515;">"Edit"</span>, <span style="color: blue;">new</span> { id=Model.ID }) |<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background-color: yellow; background-position: initial initial; background-repeat: initial initial;">@</span>Html.ActionLink(<span style="color: #a31515;">"Back to List"</span>, <span style="color: #a31515;">"Index"</span>)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">p</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
</div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<span style="color: red;"><b>Output:</b></span></div>
<div>
<span style="color: red;"><b><br /></b></span></div>
<div>
<span style="color: red;"><b>Index.View</b></span></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3S7OBCORn_1fyuShbkIXb4fUwMxQxSpxL8OFqDBLFWVC6LnEoiPtzE6ce3W8VoAwYP9cVw47ywi7PRhK8h78PLZ7WVo9Lys05z5emdKbEJbFvTPbgvzTooPp186tyBbsyUoK2WZ9p0GtE/s1600/EF8.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3S7OBCORn_1fyuShbkIXb4fUwMxQxSpxL8OFqDBLFWVC6LnEoiPtzE6ce3W8VoAwYP9cVw47ywi7PRhK8h78PLZ7WVo9Lys05z5emdKbEJbFvTPbgvzTooPp186tyBbsyUoK2WZ9p0GtE/s1600/EF8.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<br />
<b style="color: red;">Details.View</b><br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPTTZHhHsduKhvM9QgFPjWkcryh1azzCUIkcisQAu537eigledkAYCePF0hTmKlfLEw470TjnP4PEn92k4uD_6uE1EJC5BDVRvID-fDbOnkktuBQSmviaOsTzZlB4NJ9gZ71TTLnxi4Y5D/s1600/EF9.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPTTZHhHsduKhvM9QgFPjWkcryh1azzCUIkcisQAu537eigledkAYCePF0hTmKlfLEw470TjnP4PEn92k4uD_6uE1EJC5BDVRvID-fDbOnkktuBQSmviaOsTzZlB4NJ9gZ71TTLnxi4Y5D/s1600/EF9.png" /></a></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
<br /></div>
<div>
From this article you can learn how to add the stored procedure as function in the Model using Entity Framework in ASP.NET MVC.</div>
<br />
<div>
</div>
<br />
<div style="-webkit-text-stroke-width: 0px; color: black; font-family: 'Times New Roman'; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">
<div style="margin: 0px;">
<br /></div>
</div>
</div>
DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-91722103634286931932014-01-10T23:56:00.002-08:002014-01-10T23:56:42.103-08:00Deploy a web application in IIS<div dir="ltr" style="text-align: left;" trbidi="on">
In this article we are going to see how to deploy the web application in IIS, Now let we the steps to do this.<br />
<br />
1. First press windows+R to get the run window<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjN8GVVb3_OK6h48nVY4rI0vbhcIDRNJghB5jpuKQZVq4KISwYkhflE3TZDv7skKBJKe5caIn_gMUGk9YBRi9wrGCqgBnZFJJLUWFc2HYQwp3QUrJof7b3wnhEpD8nUt3YYqKjWjJhYnZsG/s1600/host1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjN8GVVb3_OK6h48nVY4rI0vbhcIDRNJghB5jpuKQZVq4KISwYkhflE3TZDv7skKBJKe5caIn_gMUGk9YBRi9wrGCqgBnZFJJLUWFc2HYQwp3QUrJof7b3wnhEpD8nUt3YYqKjWjJhYnZsG/s1600/host1.png" height="166" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<br /></div>
2. Type inetmgr in the run and press enter.<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipy6ogDK-8-fMdiE9HkZlkUQ9mXRWxW-2GMbVt3p_CkvN0IYdUPyEkscT7Ems7I0Msq0DFd2Y61SGtg_pdKop5xo9Qbn1Oxb1Jd5d-KjqOvSheMOvOTUrdTC-UhDEPjFbNOmJdeB4bOygs/s1600/host2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipy6ogDK-8-fMdiE9HkZlkUQ9mXRWxW-2GMbVt3p_CkvN0IYdUPyEkscT7Ems7I0Msq0DFd2Y61SGtg_pdKop5xo9Qbn1Oxb1Jd5d-KjqOvSheMOvOTUrdTC-UhDEPjFbNOmJdeB4bOygs/s1600/host2.png" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<br /></div>
3. Now expand the IIS and select the Default WebSite.<br />
4. Now right click the Default WebSite and select Add Application<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9sZ5CUIQLCgP4l6ewPVKHT0ZYg0_sv0yhphd7IoU5g4K3-7Iu5In06FeRQhlAW-O-046zODPJeCeCHgzCDX-lDN4zM9X6T8RDiGgfamRUbvbnmOraS4s3xokOQ-JgpZNGghz0Gpzgtzt4/s1600/host3.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh9sZ5CUIQLCgP4l6ewPVKHT0ZYg0_sv0yhphd7IoU5g4K3-7Iu5In06FeRQhlAW-O-046zODPJeCeCHgzCDX-lDN4zM9X6T8RDiGgfamRUbvbnmOraS4s3xokOQ-JgpZNGghz0Gpzgtzt4/s1600/host3.png" height="320" width="314" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
5. Now Give the Alias name and select the physical path of the application and select the Application Pool.click ok<br />
<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEU7YtkhznIl5009IuVNV-8SYA0s23_D0TBlXKVBvfT9Gvw7-sBo2IvFKJRfBCQhQLZz8WsI6RkPkJNvRIkwQqP3IqjdJRGFKELk-qOypBulr5votXpnvvd0TomWz2TP2LTkpSJc5wuIMn/s1600/host4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhEU7YtkhznIl5009IuVNV-8SYA0s23_D0TBlXKVBvfT9Gvw7-sBo2IvFKJRfBCQhQLZz8WsI6RkPkJNvRIkwQqP3IqjdJRGFKELk-qOypBulr5votXpnvvd0TomWz2TP2LTkpSJc5wuIMn/s1600/host4.png" height="221" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkjNhYmsSYGRWmHgnq5ShXtEC_fQlipWOGEBZrqzNX0i3z_S8QqNtqi1vdyqzqJi-zdsaUSSv3wf70iotGjkqMi7P6zWb-AVyHNGTl9v94H3eyRFC26toS9YsNtNMACys2TTu-0mSK-VE2/s1600/host5.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjkjNhYmsSYGRWmHgnq5ShXtEC_fQlipWOGEBZrqzNX0i3z_S8QqNtqi1vdyqzqJi-zdsaUSSv3wf70iotGjkqMi7P6zWb-AVyHNGTl9v94H3eyRFC26toS9YsNtNMACys2TTu-0mSK-VE2/s1600/host5.png" height="221" width="320" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both;">
<br /></div>
6.Expand the Default website and select the name of application that you have given as alias and right click on it.<br />
<br />
7.Select the Manage and Browse to browse the application.<br />
<div>
<br /></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUix92O20P_59YqjZ5HAkcUq_0MRED0rsFJjToOhJ0EHzhBrYzbjCh0BBOF5wxzWhgNAIN5ZggZ5s3p3ILxuutQW7r-SCF3n4ts8n6m3aieqWSExDX-vL49jR8Y4JoU_DJNVxkmch0TdvQ/s1600/host6.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgUix92O20P_59YqjZ5HAkcUq_0MRED0rsFJjToOhJ0EHzhBrYzbjCh0BBOF5wxzWhgNAIN5ZggZ5s3p3ILxuutQW7r-SCF3n4ts8n6m3aieqWSExDX-vL49jR8Y4JoU_DJNVxkmch0TdvQ/s1600/host6.png" height="225" width="320" /></a></div>
<br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiolH7d9Yq4Zys8oLvOqA8wDOqmaNeP_oVRuMFnI75VJH1DsVG2FfdkGlmfu-Lm7s-thwfUk_3HaRrYWq1IdT6_HJ44vWsTbDkbUscwtpVX6582J2kzhoxCG_M-Fb1rzSSUA6WhtBG_sp2/s1600/host7.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiolH7d9Yq4Zys8oLvOqA8wDOqmaNeP_oVRuMFnI75VJH1DsVG2FfdkGlmfu-Lm7s-thwfUk_3HaRrYWq1IdT6_HJ44vWsTbDkbUscwtpVX6582J2kzhoxCG_M-Fb1rzSSUA6WhtBG_sp2/s1600/host7.png" height="27" width="320" /></a></div>
<br />
<br />
<br />
From this post you can see how to host a web application in IIS.</div>
DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-65430163260796229462014-01-05T03:43:00.000-08:002014-01-10T22:03:55.299-08:00Remote Validation - Check the user existence in people register form ASP.NET MVC<div dir="ltr" style="text-align: left;" trbidi="on"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7wjGMOx9yy1MrvOf92p4bpAClJU2Sl0GIHFugG0hkIfRbL3qhQHMmMX6d7cHh3GOigotQaXGsQfwlb2DZBgjr4IQbIP3Mx5lvdGzAP2K2mEAgzTsw_QcA6pj4fCZ4I2HwAUQzVSLG3B4X/s1600/C%2523.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7wjGMOx9yy1MrvOf92p4bpAClJU2Sl0GIHFugG0hkIfRbL3qhQHMmMX6d7cHh3GOigotQaXGsQfwlb2DZBgjr4IQbIP3Mx5lvdGzAP2K2mEAgzTsw_QcA6pj4fCZ4I2HwAUQzVSLG3B4X/s1600/C%2523.png" /></a></div><span style="color: #666666;"><br /></span><span style="color: #666666;"><br /></span><span style="color: #666666;"><br /></span><span style="color: #666666;">In this article we are going to see how to validate the textbox value whether it is already exists,In real time we can see that user name already exist error,now we are going to implement this, For do that first we have to Create a Table and Create a model using Database first using Entity Framework.</span><br /><br /><b><span style="color: red;">Sql Script:</span></b><br /><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">create</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: blue;">table</span>People<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: grey; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">(<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">id <span style="color: blue;">int</span> <span style="color: blue;">identity</span><span style="color: grey;">(</span>1<span style="color: grey;">,</span>1<span style="color: grey;">),<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">name <span style="color: blue;">varchar</span><span style="color: grey;">(</span>30<span style="color: grey;">),<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">contact <span style="color: blue;">varchar</span><span style="color: grey;">(</span>10<span style="color: grey;">),<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">addr <span style="color: blue;">varchar</span><span style="color: grey;">(</span>200<span style="color: grey;">),<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">occupation <span style="color: blue;">varchar</span><span style="color: grey;">(</span>100<span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: grey; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">INSERT</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: blue;">INTO</span>People<span style="color: grey;">(<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> name<span style="color: grey;">,<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> contact<span style="color: grey;">,<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> addr<span style="color: grey;">,<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> occupation<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">VALUES </span><span style="color: grey; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">(<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: red;">'Rajesh'</span><span style="color: grey;">,<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: red;">'1234567'</span><span style="color: grey;">,<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: red;">'Porur'</span><span style="color: grey;">,<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: red;">'Enterprenur'<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">INSERT</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: blue;">INTO</span>People<span style="color: grey;">(<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> name<span style="color: grey;">,<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> contact<span style="color: grey;">,<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> addr<span style="color: grey;">,<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> occupation<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">VALUES </span><span style="color: grey; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">(<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: red;">'Suresh'</span><span style="color: grey;">,<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: red;">'84748467'</span><span style="color: grey;">,<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: red;">'Porur'</span><span style="color: grey;">,<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: red;">'Software Engineeer'<o:p></o:p></span></span></div><br /><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="color: grey;"><br /></span></span></div>After creating the script create a model by right click the project and add the new item of ado.net edmx and fetch the all tables present in particulaer database.Now see the designer file you can see the template.<br /><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Serializable</span>()]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">DataContractAttribute</span>(IsReference=<span style="color: blue;">true</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Person</span> : <span style="color: #2b91af;">EntityObject</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> #region</span><span style="font-family: Consolas; font-size: 9.5pt;">Factory Method<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"><summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> Create a new Person object.</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"></summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"><param name="id"></span><span style="color: green;">Initial value of the id property.</span><span style="color: grey;"></param></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: #2b91af;">Person</span> CreatePerson(<span style="color: blue;">global</span>::System.<span style="color: #2b91af;">Int32</span> id)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Person</span> person = <span style="color: blue;">new</span><span style="color: #2b91af;">Person</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> person.id = id;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> person;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> #endregion</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> #region</span><span style="font-family: Consolas; font-size: 9.5pt;">Primitive Properties<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"><summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> No Metadata Documentation available.</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"></summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">EdmScalarPropertyAttribute</span>(EntityKeyProperty=<span style="color: blue;">true</span>, IsNullable=<span style="color: blue;">false</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">DataMemberAttribute</span>()]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">global</span>::System.<span style="color: #2b91af;">Int32</span> id<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">get</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> _id;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">set</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (_id != <span style="color: blue;">value</span>)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> OnidChanging(<span style="color: blue;">value</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ReportPropertyChanging(<span style="color: #a31515;">"id"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> _id = <span style="color: #2b91af;">StructuralObject</span>.SetValidValue(<span style="color: blue;">value</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ReportPropertyChanged(<span style="color: #a31515;">"id"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> OnidChanged();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> <span style="color: blue;">global</span>::System.<span style="color: #2b91af;">Int32</span> _id;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">partial</span> <span style="color: blue;">void</span>OnidChanging(<span style="color: blue;">global</span>::System.<span style="color: #2b91af;">Int32</span> value);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">partial</span> <span style="color: blue;">void</span>OnidChanged();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"><summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> No Metadata Documentation available.</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"></summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">EdmScalarPropertyAttribute</span>(EntityKeyProperty=<span style="color: blue;">false</span>, IsNullable=<span style="color: blue;">true</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">DataMemberAttribute</span>()]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">global</span>::System.<span style="color: #2b91af;">String</span> name<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">get</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> _name;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">set</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> OnnameChanging(<span style="color: blue;">value</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ReportPropertyChanging(<span style="color: #a31515;">"name"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> _name = <span style="color: #2b91af;">StructuralObject</span>.SetValidValue(<span style="color: blue;">value</span>, <span style="color: blue;">true</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ReportPropertyChanged(<span style="color: #a31515;">"name"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> OnnameChanged();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> <span style="color: blue;">global</span>::System.<span style="color: #2b91af;">String</span> _name;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">partial</span> <span style="color: blue;">void</span>OnnameChanging(<span style="color: blue;">global</span>::System.<span style="color: #2b91af;">String</span> value);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">partial</span> <span style="color: blue;">void</span>OnnameChanged();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"><summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> No Metadata Documentation available.</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"></summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">EdmScalarPropertyAttribute</span>(EntityKeyProperty=<span style="color: blue;">false</span>, IsNullable=<span style="color: blue;">true</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">DataMemberAttribute</span>()]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">global</span>::System.<span style="color: #2b91af;">String</span> contact<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">get</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> _contact;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">set</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> OncontactChanging(<span style="color: blue;">value</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ReportPropertyChanging(<span style="color: #a31515;">"contact"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> _contact = <span style="color: #2b91af;">StructuralObject</span>.SetValidValue(<span style="color: blue;">value</span>, <span style="color: blue;">true</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ReportPropertyChanged(<span style="color: #a31515;">"contact"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> OncontactChanged();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> <span style="color: blue;">global</span>::System.<span style="color: #2b91af;">String</span> _contact;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">partial</span> <span style="color: blue;">void</span>OncontactChanging(<span style="color: blue;">global</span>::System.<span style="color: #2b91af;">String</span> value);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">partial</span> <span style="color: blue;">void</span>OncontactChanged();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"><summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> No Metadata Documentation available.</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"></summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">EdmScalarPropertyAttribute</span>(EntityKeyProperty=<span style="color: blue;">false</span>, IsNullable=<span style="color: blue;">true</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">DataMemberAttribute</span>()]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">global</span>::System.<span style="color: #2b91af;">String</span> addr<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">get</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> _addr;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">set</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> OnaddrChanging(<span style="color: blue;">value</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ReportPropertyChanging(<span style="color: #a31515;">"addr"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> _addr = <span style="color: #2b91af;">StructuralObject</span>.SetValidValue(<span style="color: blue;">value</span>, <span style="color: blue;">true</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ReportPropertyChanged(<span style="color: #a31515;">"addr"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> OnaddrChanged();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> <span style="color: blue;">global</span>::System.<span style="color: #2b91af;">String</span> _addr;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">partial</span> <span style="color: blue;">void</span>OnaddrChanging(<span style="color: blue;">global</span>::System.<span style="color: #2b91af;">String</span> value);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">partial</span> <span style="color: blue;">void</span>OnaddrChanged();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"><summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> No Metadata Documentation available.</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"></summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">EdmScalarPropertyAttribute</span>(EntityKeyProperty=<span style="color: blue;">false</span>, IsNullable=<span style="color: blue;">true</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">DataMemberAttribute</span>()]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">global</span>::System.<span style="color: #2b91af;">String</span> occupation<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">get</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> _occupation;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">set</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> OnoccupationChanging(<span style="color: blue;">value</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ReportPropertyChanging(<span style="color: #a31515;">"occupation"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> _occupation = <span style="color: #2b91af;">StructuralObject</span>.SetValidValue(<span style="color: blue;">value</span>, <span style="color: blue;">true</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ReportPropertyChanged(<span style="color: #a31515;">"occupation"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> OnoccupationChanged();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> <span style="color: blue;">global</span>::System.<span style="color: #2b91af;">String</span> _occupation;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">partial</span> <span style="color: blue;">void</span>OnoccupationChanging(<span style="color: blue;">global</span>::System.<span style="color: #2b91af;">String</span> value);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">partial</span> <span style="color: blue;">void</span>OnoccupationChanged();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> #endregion</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><br /><div class="MsoNormal"><br /></div><br />Now create a another partial class with same name, Now override the name with custom display name remote validation and bind the action and controller for remote validation like existence of user name.<br /><br /><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">MetadataType</span>(<span style="color: blue;">typeof</span>(<span style="color: #2b91af;">PersonMetaData</span>))] <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Person</span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">PersonMetaData</span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Remote</span>(<span style="color: #a31515;">"Register"</span>, <span style="color: #a31515;">"Human"</span>, ErrorMessage = <span style="color: #a31515;">"User Name Already Exists"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">DisplayName</span>(<span style="color: #a31515;">"UserName"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> name { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><span style="font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;"> }</span><br /><b><span style="color: red;"><br /></span></b><b><span style="color: red;">Controller:</span></b><br /><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">PersonEntities</span><span style="font-family: Consolas; font-size: 9.5pt;"> datas = <span style="color: blue;">new</span> <span style="color: #2b91af;">PersonEntities</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span> Index()<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span>View(datas.People.ToList());<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">JsonResult</span> Register(<span style="color: blue;">string</span>name)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> { <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span>Json(!datas.People.Any(x => x.name == name),<span style="color: #2b91af;">JsonRequestBehavior</span>.AllowGet); <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span> Create()<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span>View();<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><br /><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><br /></div><b><span style="color: red;"><br /></span></b><b><span style="color: red;">View :</span></b><br /><b><span style="color: red;"><br /></span></b><b><span style="color: orange;">Create.cshtml</span></b><br /><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@model </span><span style="font-family: Consolas; font-size: 9.5pt;">EastSolution.Models.<span style="color: #2b91af;">Person</span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@{</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> Layout = <span style="color: blue;">null</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">}</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><!</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">DOCTYPE</span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="color: red;">html</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">html</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">head</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">meta</span> <span style="color: red;">name</span><span style="color: blue;">="viewport"</span> <span style="color: red;">content</span><span style="color: blue;">="width=device-width"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">title</span><span style="color: blue;">></span>Create<span style="color: blue;"></</span><span style="color: maroon;">title</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">="../../Content/Site.css"</span> <span style="color: red;">rel</span><span style="color: blue;">="stylesheet"</span><span style="color: red;">type</span><span style="color: blue;">="text/css"</span><span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">head</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">body</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">script</span> <span style="color: red;">src</span><span style="color: blue;">="~/Scripts/jquery-1.7.1.min.js"></</span><span style="color: maroon;">script</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">script</span> <span style="color: red;">src</span><span style="color: blue;">="~/Scripts/jquery.validate.min.js"></</span><span style="color: maroon;">script</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">script</span> <span style="color: red;">src</span><span style="color: blue;">="~/Scripts/jquery.validate.unobtrusive.min.js"></</span><span style="color: maroon;">script</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span><span style="color: blue;">using</span> (Html.BeginForm()) {<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationSummary(<span style="color: blue;">true</span>)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">fieldset</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">width</span><span style="color: blue;">:500px;</span><span style="color: red;">margin-left</span><span style="color: blue;">: 298px;</span><span style="color: red;">margin-top</span><span style="color: blue;">: 58px;</span><span style="color: red;">margin-bottom</span><span style="color: blue;">:50px"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">legend</span><span style="color: blue;">></span>People Registry<span style="color: blue;"></</span><span style="color: maroon;">legend</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.LabelFor(model => model.name)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span><span style="color: red;">class</span><span style="color: blue;">="editor-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.EditorFor(model => model.name)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationMessageFor(model => model.name)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.LabelFor(model => model.contact)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.EditorFor(model => model.contact)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationMessageFor(model => model.contact)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.LabelFor(model => model.addr)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.EditorFor(model => model.addr)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationMessageFor(model => model.addr)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.LabelFor(model => model.occupation)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.EditorFor(model => model.occupation)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationMessageFor(model => model.occupation)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">p</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">input</span> <span style="color: red;">type</span><span style="color: blue;">="submit"</span> <span style="color: red;">value</span><span style="color: blue;">="Create"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">p</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">fieldset</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ActionLink(<span style="color: #a31515;">"Back to List"</span>, <span style="color: #a31515;">"Index"</span>)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">body</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">html</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><br /><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><br /></div><b><span style="color: orange;"><br /></span></b><b><span style="color: orange;"><br /></span></b><b><span style="color: orange;">Index.cshtml</span></b><br /><br /><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@model </span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">IEnumerable</span><span style="font-family: Consolas; font-size: 9.5pt;"><EastSolution.Models.<span style="color: #2b91af;">Person</span>><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@{</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> Layout = <span style="color: blue;">null</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">}</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><!</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">DOCTYPE</span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="color: red;">html</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">html</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">head</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">meta</span> <span style="color: red;">name</span><span style="color: blue;">="viewport"</span> <span style="color: red;">content</span><span style="color: blue;">="width=device-width"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">title</span><span style="color: blue;">></span>Index<span style="color: blue;"></</span><span style="color: maroon;">title</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">link</span> <span style="color: red;">href</span><span style="color: blue;">="../../Content/Site.css"</span> <span style="color: red;">rel</span><span style="color: blue;">="stylesheet"</span><span style="color: red;">type</span><span style="color: blue;">="text/css"</span><span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">head</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">body</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">p</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">width</span><span style="color: blue;">:500px;</span><span style="color: red;">margin-left</span><span style="color: blue;">: 298px;</span><span style="color: red;">margin-top</span><span style="color: blue;">: 58px;</span><span style="color: red;">margin-bottom</span><span style="color: blue;">:40px"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ActionLink(<span style="color: #a31515;">"Create New"</span>, <span style="color: #a31515;">"Create"</span>)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">p</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">table</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">width</span><span style="color: blue;">:500px;</span><span style="color: red;">margin-left</span><span style="color: blue;">: 298px;</span><span style="color: red;">margin-top</span><span style="color: blue;">: 58px;"></span> <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">th</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DisplayNameFor(model => model.name)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">th</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">th</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DisplayNameFor(model => model.contact)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">th</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">th</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DisplayNameFor(model => model.addr)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">th</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">th</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DisplayNameFor(model => model.occupation)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">th</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">th</span><span style="color: blue;">></</span><span style="color: maroon;">th</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span><span style="color: blue;">foreach</span> (<span style="color: blue;">var</span> item <span style="color: blue;">in</span> Model) {<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DisplayFor(modelItem => item.name)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DisplayFor(modelItem => item.contact)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DisplayFor(modelItem => item.addr)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">padding</span><span style="color: blue;">:2px"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DisplayFor(modelItem => item.occupation)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ActionLink(<span style="color: #a31515;">"Edit"</span>, <span style="color: #a31515;">"Edit"</span>, <span style="color: blue;">new</span>{ id=item.id }) |<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ActionLink(<span style="color: #a31515;">"Details"</span>, <span style="color: #a31515;">"Details"</span>, <span style="color: blue;">new</span> { id=item.id }) |<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ActionLink(<span style="color: #a31515;">"Delete"</span>, <span style="color: #a31515;">"Delete"</span>, <span style="color: blue;">new</span>{ id=item.id })<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">table</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">body</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><br /><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">html</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><br /><br /><b><span style="color: blue;">Output:</span></b><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZxYVZ-9jY1dtmxqqGRj-t63UQXumpz-pRAnKILWunWAxhk3YAO0IrJcU-wT4XqmmN2Fdw8vo7-SoXDB-x_zvKlXrcoZ0IVQW9sd-HZjvVyd70spE6kXRI0-d35fYUyoypSEkdPhvkuiOf/s1600/remote1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZxYVZ-9jY1dtmxqqGRj-t63UQXumpz-pRAnKILWunWAxhk3YAO0IrJcU-wT4XqmmN2Fdw8vo7-SoXDB-x_zvKlXrcoZ0IVQW9sd-HZjvVyd70spE6kXRI0-d35fYUyoypSEkdPhvkuiOf/s1600/remote1.png" /></a></div><br /><br />From this article you can learn how to create the remote validation in asp.net MVC</div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-69013847014433290522014-01-04T20:13:00.000-08:002014-01-10T22:03:55.345-08:00Passing the values between the windows forms - C#<div dir="ltr" style="text-align: left;" trbidi="on">In this article we are going to see , how to pass the value between the forms.First let we see how to pass the value from the child screen to the parent form,next parent form to child form. For transfer the data we have to use the Property.<br /><br /><b><span style="color: red;">Child form to Parent Form:</span></b><br />In this sample we are going to launch student form, in which the textbox is readonly we cant able to enter the value, the value should be calculate from the child form then it should fill the textbox in the parent form.<br /><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"><b><span style="color: red;">Parent Form:</span></b><span style="color: blue;"><o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">public</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">ParentForm</span> : <span style="color: #2b91af;">Form</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> ParentForm()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> InitializeComponent();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> <span style="color: blue;">void</span>button1_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">ChildForm</span> cf = <span style="color: blue;">new</span><span style="color: #2b91af;">ChildForm</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cf.ShowDialog();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> textBox1.Text = cf.TotalVaue.ToString();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"><b><span style="color: red;">Child Form:</span></b><span style="color: blue;"><o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">public</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">ChildForm</span> : <span style="color: #2b91af;">Form</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">int</span> TotalVaue { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> <span style="color: blue;">int</span> a;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> <span style="color: blue;">int</span> b;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> ChildForm()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> InitializeComponent();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> <span style="color: blue;">void</span>button1_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (<span style="color: blue;">string</span>.IsNullOrEmpty(textBox1.Text) || <span style="color: blue;">string</span>.IsNullOrEmpty(textBox2.Text))<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">MessageBox</span>.Show(<span style="color: #a31515;">":Please fill the details to calculate the operation "</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">else</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">try</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> a = <span style="color: blue;">int</span>.Parse(textBox1.Text);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> b = <span style="color: blue;">int</span>.Parse(textBox2.Text);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> TotalVaue = a + b;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">this</span>.Close();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">catch</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">MessageBox</span>.Show(<span style="color: #a31515;">":Please fill the details to calculate the operation "</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><br /><div class="MsoNormal"><br /></div><div class="MsoNormal"><o:p><br /></o:p></div><div class="MsoNormal"><o:p><b><span style="color: red;">Output:</span></b></o:p></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipcqbi6fq37eY7cDTAH_WC4XNw5_98TsTAj5lci_ISJYqCKrbI6MXG0C9mR5ltk5KFW8asnik47NxCEwsmsSHjcrdq0oxOL4LPlyEN4pCmKMrWoJJiO_yMKlzy5uEQnYeCcpFYlZXqBujB/s1600/Form11.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEipcqbi6fq37eY7cDTAH_WC4XNw5_98TsTAj5lci_ISJYqCKrbI6MXG0C9mR5ltk5KFW8asnik47NxCEwsmsSHjcrdq0oxOL4LPlyEN4pCmKMrWoJJiO_yMKlzy5uEQnYeCcpFYlZXqBujB/s1600/Form11.png" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPdjqNHrKcQRSjzPzd_w5egjoYox_5NugyFCEtE5jquOZRYd0OgYGrvJwBBlFsQVg2lIUys9JHhOR6D7v0K33rLGj7QVW_TmCHfkMRwRix8_wi2y4_bglrmErtqhgGlaA0hyphenhyphen_DJx1PZ7U6/s1600/From12.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiPdjqNHrKcQRSjzPzd_w5egjoYox_5NugyFCEtE5jquOZRYd0OgYGrvJwBBlFsQVg2lIUys9JHhOR6D7v0K33rLGj7QVW_TmCHfkMRwRix8_wi2y4_bglrmErtqhgGlaA0hyphenhyphen_DJx1PZ7U6/s1600/From12.png" /></a></div><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhruN1of7AAcSU0qWU0SfsExVhvJuDiV4T2P-qCsPFUEDRobyjK1YzOQ9HwNYMJyOZZjRaUZP8J27xmoPHFL98LZZfa0521ubnBaX8yPAFsB0XtKBszraDB9MZE36BGD-gTrYd5ahtk-3sF/s1600/From13.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhruN1of7AAcSU0qWU0SfsExVhvJuDiV4T2P-qCsPFUEDRobyjK1YzOQ9HwNYMJyOZZjRaUZP8J27xmoPHFL98LZZfa0521ubnBaX8yPAFsB0XtKBszraDB9MZE36BGD-gTrYd5ahtk-3sF/s1600/From13.png" /></a></div><div class="MsoNormal"><o:p><br /></o:p></div><br /><br /><br /><b><span style="color: red;">Parent Form to Child Form:</span></b><br />In this second sample we are going to pass the value to child form from parent form using property. So here in this sample Student name is pass from the parent form to child form.<br /><br /><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Parent Form:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">if</span><span style="font-family: Consolas; font-size: 9.5pt;"> (<span style="color: blue;">string</span>.IsNullOrEmpty(textBox2.Text))<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">MessageBox</span>.Show(<span style="color: #a31515;">"Please fill the student name"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">else</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">ChildForm</span> cf = <span style="color: blue;">new</span> <span style="color: #2b91af;">ChildForm</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cf.StudentName = textBox2.Text;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cf.ShowDialog();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> textBox1.Text = cf.TotalVaue.ToString();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><o:p><br /></o:p></div><div class="MsoNormal"><b><span style="color: red;">Child Form :</span></b></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">private</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">void</span>ChildForm_Load(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> label4.Text = StudentName;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal"><br /></div><br /><div class="MsoNormal"><br /></div><div class="MsoNormal"><o:p><b><span style="color: red;">Output:</span></b></o:p></div><div class="MsoNormal"><o:p><b><span style="color: red;"><br /></span></b></o:p></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDejH2tXBvaxTQZMMoqL91Ro71rB068FH4-0NKeQmRXdQjFsGhNdUQRTYwFBdsZRsPQeJ2YQEXH4PKIGrPku8g0sGghZSDwKP7ON-yF5Aex4KBToxuIAGVIgODPmplWlbuzq4kz9glXPTn/s1600/From21.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDejH2tXBvaxTQZMMoqL91Ro71rB068FH4-0NKeQmRXdQjFsGhNdUQRTYwFBdsZRsPQeJ2YQEXH4PKIGrPku8g0sGghZSDwKP7ON-yF5Aex4KBToxuIAGVIgODPmplWlbuzq4kz9glXPTn/s1600/From21.png" /></a></div><div class="MsoNormal"><o:p><b><span style="color: red;"><br /></span></b></o:p></div><div class="MsoNormal"><o:p><b><span style="color: red;"><br /></span></b></o:p></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIXVbhyphenhyphenknZJv7eSI8PL3Fcl73j9X5Xm_hlNMmAbCKZZlOQrEamodAmK42V9GV7aUVms-XS1iP10HZ44-oqnZfxOVypmk7zNJdGdEmiOwRX-ohf7x1aLIIw2Ln9iR2NCbrZOZ82ApI0CeVB/s1600/From22.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIXVbhyphenhyphenknZJv7eSI8PL3Fcl73j9X5Xm_hlNMmAbCKZZlOQrEamodAmK42V9GV7aUVms-XS1iP10HZ44-oqnZfxOVypmk7zNJdGdEmiOwRX-ohf7x1aLIIw2Ln9iR2NCbrZOZ82ApI0CeVB/s1600/From22.png" /></a></div><div class="MsoNormal"><o:p><b><span style="color: red;"><br /></span></b></o:p></div><div class="MsoNormal"><o:p><b><span style="color: red;"><br /></span></b></o:p></div><div class="MsoNormal"><o:p><b><span style="color: red;"><br /></span></b></o:p></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPcZjFmHUEhBol_2dz3HSx_pt37_Jt_W_z5BzJ9hI2MAlWUtj0y33QLI5B4R71qpa-haF3M_fqWHEckOzklNni0k5GHc7jxdgR6f8Vqb8i9nXVifgWMCesHZzns1VU4KzPF9Qs5wSwclmP/s1600/Form23.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgPcZjFmHUEhBol_2dz3HSx_pt37_Jt_W_z5BzJ9hI2MAlWUtj0y33QLI5B4R71qpa-haF3M_fqWHEckOzklNni0k5GHc7jxdgR6f8Vqb8i9nXVifgWMCesHZzns1VU4KzPF9Qs5wSwclmP/s1600/Form23.png" /></a></div><div class="MsoNormal"><o:p><br /></o:p></div><br /><br /><br />I hope from this article you can learn how to pass the data from the parent form to the child form.<br /><br /><br /><br /></div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-4039018630646213882014-01-04T18:55:00.000-08:002014-01-10T22:03:55.265-08:00Convert Xml in to CSV in c#<div dir="ltr" style="text-align: left;" trbidi="on"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7wjGMOx9yy1MrvOf92p4bpAClJU2Sl0GIHFugG0hkIfRbL3qhQHMmMX6d7cHh3GOigotQaXGsQfwlb2DZBgjr4IQbIP3Mx5lvdGzAP2K2mEAgzTsw_QcA6pj4fCZ4I2HwAUQzVSLG3B4X/s1600/C%2523.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7wjGMOx9yy1MrvOf92p4bpAClJU2Sl0GIHFugG0hkIfRbL3qhQHMmMX6d7cHh3GOigotQaXGsQfwlb2DZBgjr4IQbIP3Mx5lvdGzAP2K2mEAgzTsw_QcA6pj4fCZ4I2HwAUQzVSLG3B4X/s1600/C%2523.png" /></a></div><br />In this article we are going to see how to convert the xml in to CSV format, based on the custom delimiters.<br /><br />Files:<br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZTDKkoW7gpPn_8v-n1_eHCC2un7kONJQOZ75ia0AqbMd99N9XfojD3E3lZP9rCqBk16gn2rPp2bhwKSoiRpHfv59gyfnH76OPC0v1_wweN2EwwJr0w9dF3xfVSbRs5dFsGPnHr6PJxil5/s1600/csv.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhZTDKkoW7gpPn_8v-n1_eHCC2un7kONJQOZ75ia0AqbMd99N9XfojD3E3lZP9rCqBk16gn2rPp2bhwKSoiRpHfv59gyfnH76OPC0v1_wweN2EwwJr0w9dF3xfVSbRs5dFsGPnHr6PJxil5/s1600/csv.png" /></a></div><br />Source code for Convert Xml in to CSV:<br /><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">class</span> <span style="color: #2b91af;">XmlToCsv</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">enum</span> <span style="color: #2b91af;">RowDelimit</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> Default,<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> NewLine,<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> Space,<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> Ambescent,<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> Dollar<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">enum</span> <span style="color: #2b91af;">ColumnDelimit</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> Default,<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> Comma,<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> TabSpace,<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> Percentage,<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> OrSymbol,<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> Dot<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">enum</span> <span style="color: #2b91af;">DataArrange</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> Element,<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> Attribute<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: #2b91af;">RowDelimit</span> RowDelimiter { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: #2b91af;">ColumnDelimit</span> ColumnDelimiter { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">void</span> FetchRowSeparater(<span style="color: #2b91af;">RowDelimit</span>delimit, <span style="color: blue;">out</span> <span style="color: blue;">string</span>separater)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">switch</span> (delimit)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">case</span> <span style="color: #2b91af;">RowDelimit</span>.NewLine:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">case</span> <span style="color: #2b91af;">RowDelimit</span>.Default:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> separater = <span style="color: #2b91af;">Environment</span>.NewLine;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">break</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">case</span> <span style="color: #2b91af;">RowDelimit</span>.Space:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> separater = <span style="color: #a31515;">" "</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">break</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">case</span> <span style="color: #2b91af;">RowDelimit</span>.Dollar:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> separater = <span style="color: #a31515;">"$"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">break</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">case</span> <span style="color: #2b91af;">RowDelimit</span>.Ambescent:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> separater = <span style="color: #a31515;">"&"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">break</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">default</span>:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> separater = <span style="color: #2b91af;">Environment</span>.NewLine;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">break</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">void</span> FetchColumnSeparater(<span style="color: #2b91af;">ColumnDelimit</span>delimit, <span style="color: blue;">out</span> <span style="color: blue;">string</span>separater)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">switch</span> (delimit)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">case</span> <span style="color: #2b91af;">ColumnDelimit</span>.Comma:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">case</span> <span style="color: #2b91af;">ColumnDelimit</span>.Default:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> separater = <span style="color: #a31515;">","</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">break</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">case</span> <span style="color: #2b91af;">ColumnDelimit</span>.Dot:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> separater = <span style="color: #a31515;">"."</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">break</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">case</span> <span style="color: #2b91af;">ColumnDelimit</span>.OrSymbol:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> separater = <span style="color: #a31515;">"|"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">break</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">case</span> <span style="color: #2b91af;">ColumnDelimit</span>.Percentage:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> separater = <span style="color: #a31515;">"%"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">break</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">case</span> <span style="color: #2b91af;">ColumnDelimit</span>.TabSpace:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> separater = <span style="color: #a31515;">"\t"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">break</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">default</span>:<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> separater = <span style="color: #a31515;">","</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">break</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Convert(<span style="color: blue;">string</span>xmlfilepath, <span style="color: blue;">string</span> csvpath, <span style="color: blue;">string</span> datatag, <span style="color: #2b91af;">DataArrange</span>arrange, <span style="color: #2b91af;">RowDelimit</span> rdelimit, <span style="color: #2b91af;">ColumnDelimit</span> cdelimit)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">try</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">StringBuilder</span> builder = <span style="color: blue;">new</span> <span style="color: #2b91af;">StringBuilder</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">XDocument</span> doc = <span style="color: #2b91af;">XDocument</span>.Load(xmlfilepath);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">string</span> Rowseparater = <span style="color: blue;">string</span>.Empty;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> FetchRowSeparater(rdelimit, <span style="color: blue;">out</span>Rowseparater);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">string</span> Columnseparater = <span style="color: blue;">string</span>.Empty;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> FetchColumnSeparater(cdelimit, <span style="color: blue;">out</span>Columnseparater);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">foreach</span> (<span style="color: #2b91af;">XElement</span>data <span style="color: blue;">in</span> doc.Descendants(datatag))<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (arrange == <span style="color: #2b91af;">DataArrange</span>.Element)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">foreach</span> (<span style="color: #2b91af;">XElement</span> innnerval <span style="color: blue;">in</span> data.Elements())<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> builder.Append(innnerval.Value);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> builder.Append(Columnseparater);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">else</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">foreach</span> (<span style="color: #2b91af;">XAttribute</span> innerval <span style="color: blue;">in</span> data.Attributes())<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> builder.Append(innerval.Value);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> builder.Append(Columnseparater);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> builder.Append(Rowseparater);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">File</span>.AppendAllText(csvpath, builder.ToString());<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">catch</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">throw</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><br /><div class="MsoNormal"><br /></div><b><span style="color: red;">Input Xml File:</span></b><br /><br /><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #f8f8f8; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><Employees><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #f8f8f8; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><Employee name="Rajesh" address="Chennai" dept="IT" /><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #f8f8f8; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><Employee name="Suresh" address="Chennai" dept="CSE" /><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #f8f8f8; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><Employee name="Siva" address="US" dept="R&amp;D" /><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #f8f8f8; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"></Employees><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><br /></div><br /><div class="MsoNormal"><br /></div><div class="MsoNormal">Read the xml which have values in Attributes and convert that into CSV.</div><div class="MsoNormal"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> try</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">XmlToCsv</span>.Convert(<span style="color: #a31515;">@"D:\data\attrxml.xml"</span>, <span style="color: #a31515;">@"D:\data\rowxml.csv"</span>, <span style="color: #a31515;">"Employee"</span>, <span style="color: #2b91af;">XmlToCsv</span>.<span style="color: #2b91af;">DataArrange</span>.Attribute, <span style="color: #2b91af;">XmlToCsv</span>.<span style="color: #2b91af;">RowDelimit</span>.NewLine, <span style="color: #2b91af;">XmlToCsv</span>.<span style="color: #2b91af;">ColumnDelimit</span>.Comma);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Console</span>.Write(<span style="color: #a31515;">"Done"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">catch</span> (<span style="color: #2b91af;">Exception</span>ex)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Console</span>.Write(ex.Message);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Console</span>.Read();<o:p></o:p></span></div><div class="MsoNormal"><br /></div><div class="MsoNormal">Read the xml which have values in Elements and convert that into CSV.</div><div class="MsoNormal"><br /></div><div class="MsoNormal"><b><span style="color: red;">Input Xml File:</span></b></div><div class="MsoNormal"><b><span style="color: red;"><br /></span></b></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><Employees></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><Employee></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><name></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Rajesh</span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"></name></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><address></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Chennai</span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"></address></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><dept></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">IT</span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"></dept></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"></Employee></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><Employee></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><name></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Suresh</span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"></name></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><address></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Chennai</span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"></address></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><dept></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">CSE</span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"></dept></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"></Employee></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><Employee></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><name></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Siva</span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"></name></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><address></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">US</span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"></address></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><dept></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">R</span><span style="color: #f8f8f8; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">&amp;</span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">D</span><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"></dept></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"></Employee></span><span style="color: #cccccc; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #9b703f; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"></Employees></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div><div class="MsoNormal"> </div><div class="MsoNormal"><br /></div><div class="MsoNormal"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">try</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">XmlToCsv</span>.Convert(<span style="color: #a31515;">@"D:\data\elementxml.xml"</span>, <span style="color: #a31515;">@"D:\data\elemntxml.csv"</span>, <span style="color: #a31515;">"Employee"</span>, <span style="color: #2b91af;">XmlToCsv</span>.<span style="color: #2b91af;">DataArrange</span>.Element, <span style="color: #2b91af;">XmlToCsv</span>.<span style="color: #2b91af;">RowDelimit</span>.NewLine, <span style="color: #2b91af;">XmlToCsv</span>.<span style="color: #2b91af;">ColumnDelimit</span>.Comma);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Console</span>.Write(<span style="color: #a31515;">"Done"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">catch</span> (<span style="color: #2b91af;">Exception</span>ex)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Console</span>.Write(ex.Message);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Console</span>.Read();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><b><span style="color: red;">Output:</span></b></div><div class="MsoNormal"><br /></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #f8f8f8; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Rajesh,Chennai,IT,<o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #f8f8f8; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Suresh,Chennai,CSE,<o:p></o:p></span></div><div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;"><span style="color: #f8f8f8; font-family: Consolas; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Siva,US,R&D,<o:p></o:p></span></div><div class="MsoNormal"><br /></div><br /><div class="MsoNormal">You can change the delimiters based on your requirements.</div><br /><br />From this post you can understand how to implement how to xml to csv format.</div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-75328219904561705112014-01-01T18:00:00.000-08:002014-01-10T22:03:55.362-08:00Operator Overloading in C#<div dir="ltr" style="text-align: left;" trbidi="on">In this article we are going to see the operator overloading , operator overloading is a concept where we can overload the method using the Operator , in which the operation between the interaction objects can be defined based on symbol.Let we see a sample scenario where we can see the stringoperation is a class which have the MethodName is string, when two objects are interact with summation operator then the<br />result will be the concat of the MethodName with intermediate , symbol<br /><br />C#<br /><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">StringOperation</span> operation1 = <span style="color: blue;">new</span> <span style="color: #2b91af;">StringOperation</span>() { MethodName=<span style="color: #a31515;">"public"</span>};<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">StringOperation</span> operation2 = <span style="color: blue;">new</span> <span style="color: #2b91af;">StringOperation</span>() { MethodName = <span style="color: #a31515;">"private"</span> };<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">StringOperation</span> operation3 = operation1 + operation2;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Console</span>.WriteLine(operation3.ToString());<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Console</span>.Read();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">class</span> <span style="color: #2b91af;">StringOperation</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span>MethodName { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: #2b91af;">StringOperation</span> <span style="color: blue;">operator</span>+ (<span style="color: #2b91af;">StringOperation</span> operation1, <span style="color: #2b91af;">StringOperation</span> operation2)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">StringOperation</span>() {MethodName = operation1.MethodName+<span style="color: #a31515;">","</span>+operation2.MethodName };<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">override</span> <span style="color: blue;">string</span> ToString()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> MethodName;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><br /><div class="MsoNormal"><br /></div><br /><b><span style="color: red;">Output:</span></b><br />public,private<br /><br />From this article you can see how to implement the Operator overloading.</div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-75091284321713091012014-01-01T17:38:00.000-08:002014-01-10T22:03:55.359-08:00Access the Controls inside the Thread - Winforms<div dir="ltr" style="text-align: left;" trbidi="on">In this article we are going to see how to update the controls in the Thread, because when you try to update the value or change the value or try to access the control in the Thread , it will return back cross thread operation or Invalid operation exception.<br /><br />To access the controls inside the thread we have to use the Delagates, which will use to invoke a Method having same signature of delegates.<br /><br />To access the controls inside the thread, we can go for another process called background worker in which we can access the controls in the report progress<br /><br />Let we some sample we have a Listview and a button, on button click we have to start a thread and do some operation , after a some particular time i need to add some values to the listview.<br /><br />Code: Delegate<br /><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">delegate</span> <span style="color: blue;">void</span> <span style="color: #2b91af;">UpdateView</span>(<span style="color: blue;">object</span> sender);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">void</span> Update(<span style="color: blue;">object</span> sender)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">var</span> f = listView1.Items.Add(<span style="color: #a31515;">"Text"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> f.SubItems.Add(<span style="color: #a31515;">"1"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> f.SubItems.Add(<span style="color: #a31515;">"2"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> <span style="color: blue;">void</span>CallThread()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">UpdateView</span> view = <span style="color: blue;">new</span><span style="color: #2b91af;">UpdateView</span>(Update); <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> listView1.BeginInvoke(view,<span style="color: blue;">new</span> <span style="color: blue;">object</span>[]{<span style="color: blue;">this</span>});<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> <span style="color: blue;">void</span>button1_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Thread</span> th = <span style="color: blue;">new</span> <span style="color: #2b91af;">Thread</span>(CallThread);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> th.Start();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><br /><b><span style="color: red;"> Code BackgroundWorker</span></b><br /><div class="MsoNormal"><o:p> In background worker we are creating a method which will do the process and then when ever we requires to update anything we have to invoke a report progress where we can write code for access the controls present in the UI. first parameter specify the percentage and the second parameter specify the any values that need to be passed from the method to the report progress , this will use in update the progress bar while running a long run process.</o:p><br /><o:p><br /></o:p></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Collections.Generic;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.ComponentModel;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Data;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Drawing;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Linq;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Text;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Windows.Forms;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Threading;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">namespace</span><span style="font-family: Consolas; font-size: 9.5pt;"> WindowsFormsApplication1<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Form1</span> : <span style="color: #2b91af;">Form</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">BackgroundWorker</span> worker = <span style="color: blue;">new</span><span style="color: #2b91af;">BackgroundWorker</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> Form1()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> InitializeComponent();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> worker.WorkerReportsProgress = <span style="color: blue;">true</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> worker.WorkerSupportsCancellation = <span style="color: blue;">true</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> worker.DoWork += <span style="color: blue;">new</span> <span style="color: #2b91af;">DoWorkEventHandler</span>(worker_DoWork);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> worker.ProgressChanged += <span style="color: blue;">new</span> <span style="color: #2b91af;">ProgressChangedEventHandler</span>(worker_ProgressChanged);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> worker.RunWorkerCompleted += <span style="color: blue;">new</span> <span style="color: #2b91af;">RunWorkerCompletedEventHandler</span>(worker_RunWorkerCompleted);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">void</span> LoadValues()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">for</span> (<span style="color: blue;">int</span> i = 0; i < 10; i++)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Thread</span>.Sleep(1000);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (i % 2 == 0)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> worker.ReportProgress(i, <span style="color: blue;">null</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">void</span> worker_RunWorkerCompleted(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">RunWorkerCompletedEventArgs</span>e)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> listView1.Items.Add(<span style="color: #a31515;">"Completed"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">void</span> worker_DoWork(<span style="color: blue;">object</span>sender, <span style="color: #2b91af;">DoWorkEventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> LoadValues();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">void</span> worker_ProgressChanged(<span style="color: blue;">object</span>sender, <span style="color: #2b91af;">ProgressChangedEventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> listView1.Items.Add(e.ProgressPercentage.ToString());<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> <span style="color: blue;">void</span>Form1_Load(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> <span style="color: blue;">void</span>button1_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> worker.RunWorkerAsync();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal"><o:p> </o:p></div><div class="MsoNormal"><o:p> Output:</o:p></div><div class="MsoNormal"><o:p><br /></o:p></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMQavqqgMTTXDhtAu7oxpTMc7V_2ED-x75VX4uA-_Ku6gASbqwTGBb0CtRdd0e2FdqMA9cstRAMm8BfaMbokVd0YL-suBIQVwNTRF7Qg35KkbOtuf2DOvDMfbo2nTF-nkh6qZTG0mV2yv5/s1600/BackgroundWorker'.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMQavqqgMTTXDhtAu7oxpTMc7V_2ED-x75VX4uA-_Ku6gASbqwTGBb0CtRdd0e2FdqMA9cstRAMm8BfaMbokVd0YL-suBIQVwNTRF7Qg35KkbOtuf2DOvDMfbo2nTF-nkh6qZTG0mV2yv5/s1600/BackgroundWorker'.png" /></a></div><div class="MsoNormal"><o:p><br /></o:p></div><br /><br /><br />From this article you can learn how to access the controls inside the thread operation.</div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-4561006358798800352014-01-01T15:38:00.000-08:002014-01-10T22:03:55.272-08:00Create a HtmlHelper Methods - ASP.NET MVC<div dir="ltr" style="text-align: left;" trbidi="on">In this article we are going to see how to create a custom htmlhelper methods, which are used to generate the tags in MVC. what is Html Helper method for ex: in MVC we can see the <b><span style="color: orange;">Html.DisplayFor()</span></b> is one of the Html Helper.<br /><br />Now in our scenario we are going to create helper method for Button save and image. For button two overloads methods are created.<br /><br /><b><span style="color: red;">HTML HELPER</span></b>:<br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Collections.Generic;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Linq;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web.Mvc;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">namespace</span><span style="font-family: Consolas; font-size: 9.5pt;"> EmpApp.HtmlHelpers<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">CustomHtmlHelper</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: #2b91af;">IHtmlString</span> SubmitButton(<span style="color: blue;">this</span><span style="color: #2b91af;">HtmlHelper</span> helper, <span style="color: blue;">string</span>val,<span style="color: blue;">string</span> classname)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">TagBuilder</span> tag = <span style="color: blue;">new</span><span style="color: #2b91af;">TagBuilder</span>(<span style="color: #a31515;">"input"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> tag.Attributes.Add(<span style="color: #a31515;">"type"</span>, <span style="color: #a31515;">"submit"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> tag.Attributes.Add(<span style="color: #a31515;">"value"</span>, val);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> tag.Attributes.Add(<span style="color: #a31515;">"id"</span>, val);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> tag.Attributes.Add(<span style="color: #a31515;">"id"</span>, classname);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">MvcHtmlString</span>(tag.ToString(<span style="color: #2b91af;">TagRenderMode</span>.SelfClosing));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: #2b91af;">IHtmlString</span> SubmitButton(<span style="color: blue;">this</span><span style="color: #2b91af;">HtmlHelper</span> helper, <span style="color: blue;">string</span>val)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">TagBuilder</span> tag = <span style="color: blue;">new</span><span style="color: #2b91af;">TagBuilder</span>(<span style="color: #a31515;">"input"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> tag.Attributes.Add(<span style="color: #a31515;">"type"</span>,<span style="color: #a31515;">"submit"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> tag.Attributes.Add(<span style="color: #a31515;">"value"</span>,val);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> tag.Attributes.Add(<span style="color: #a31515;">"id"</span>,val);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">MvcHtmlString</span>(tag.ToString(<span style="color: #2b91af;">TagRenderMode</span>.SelfClosing));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: #2b91af;">IHtmlString</span> Image(<span style="color: blue;">this</span><span style="color: #2b91af;">HtmlHelper</span> helper, <span style="color: blue;">string</span>src, <span style="color: blue;">string</span> alt)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">TagBuilder</span> tag = <span style="color: blue;">new</span><span style="color: #2b91af;">TagBuilder</span>(<span style="color: #a31515;">"img"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> tag.Attributes.Add(<span style="color: #a31515;">"src"</span>, <span style="color: #2b91af;">VirtualPathUtility</span>.ToAbsolute(src));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> tag.Attributes.Add(<span style="color: #a31515;">"alt"</span>, alt);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">MvcHtmlString</span>(tag.ToString(<span style="color: #2b91af;">TagRenderMode</span>.SelfClosing));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div><br /><div class="MsoNormal"><br /></div><b><span style="color: red;">Razor View Code</span></b>:<br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@model </span><span style="font-family: Consolas; font-size: 9.5pt;">EmpApp.Models.<span style="color: #2b91af;">Person</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@{</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ViewBag.Title = <span style="color: #a31515;">"PersonInfo"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">}</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">div</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.EditorForModel() <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.SubmitButton(<span style="color: #a31515;">"Save"</span>)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.Image(<span style="color: #a31515;">"~/sam.jpeg"</span>,<span style="color: #a31515;">"Sample"</span>)<o:p></o:p></span></div><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">div</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><br /></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><br /></span></div><b><span style="color: red;">Web.Config</span></b>:<br />Add the namespace in the web.config EmpApp.HtmlHelpers<br /><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">system.web.webPages.razor</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> <</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">host</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">factoryType</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35</span>"<span style="color: blue;"> /></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> <</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">pages</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">pageBaseType</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">System.Web.Mvc.WebViewPage</span>"<span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> <</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">namespaces</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> <</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">add</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">namespace</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">System.Web.Mvc</span>"<span style="color: blue;"> /></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> <</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">add</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">namespace</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">System.Web.Mvc.Ajax</span>"<span style="color: blue;"> /></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> <</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">add</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">namespace</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">System.Web.Mvc.Html</span>"<span style="color: blue;"> /></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> <</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">add</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">namespace</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">System.Web.Optimization</span>"<span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> <</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">add</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">namespace</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">System.Web.Routing</span>"<span style="color: blue;"> /></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> <</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">add</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">namespace</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">EmpApp.HtmlHelpers</span>"<span style="color: blue;"> /></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">namespaces</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">pages</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">system.web.webPages.razor</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><br /><div class="MsoNormal"><br /></div><b><span style="color: red;">Output</span></b><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0HO3DiqQsPeLkHp_IexbY9s3_kCHwe7XH6uPYo4ZI6o3jNTcXgD0QSL-SrVgm9OzaEJnSZVJX0qI17cvVH9HIUTLHyX9wWmICEjYQPkT6WnqjjbbwIuHf1FGwXnpISWd9ABvCDZ9H76lq/s1600/htmlhelper.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg0HO3DiqQsPeLkHp_IexbY9s3_kCHwe7XH6uPYo4ZI6o3jNTcXgD0QSL-SrVgm9OzaEJnSZVJX0qI17cvVH9HIUTLHyX9wWmICEjYQPkT6WnqjjbbwIuHf1FGwXnpISWd9ABvCDZ9H76lq/s320/htmlhelper.png" width="288" /></a></div><br /><br />From this article i hope you can learn how to create a custom html helper methods in MVC.</div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-40458245219486030502014-01-01T02:57:00.000-08:002014-01-10T22:03:55.267-08:00Get the values of multiselect Listbox in postback - ASP.NET MVC<div dir="ltr" style="text-align: left;" trbidi="on">In this article we are going to see the how to get the values from the multi select Listbox, To get the values from the multi select we have to pass a IEnumerable of string to the first parameter, and the second parameter must have the IEnumerable of SelectListItem, To pass this both items we have to create a class template and make a strongly typed view.<br /><br />View<br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@model </span><span style="font-family: Consolas; font-size: 9.5pt;">EmpApp.Models.<span style="color: #2b91af;">SubjectListView</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@{</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ViewBag.Title = <span style="color: #a31515;">"List"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">}</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> (Html.BeginForm())<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ListBoxFor(x => x.SelectItems, Model.Subjects, <span style="color: blue;">new</span> { size = 6 })<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">input</span> <span style="color: red;">type</span><span style="color: blue;">="submit"</span><span style="color: red;">value</span><span style="color: blue;">="Submit"</span><span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><br /><div class="MsoNormal"><br /></div>C#<br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">HttpGet</span>]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span>List()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">var</span> list = <span style="color: blue;">new</span> <span style="color: #2b91af;">List</span><<span style="color: #2b91af;">SelectListItem</span>>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">foreach</span> (<span style="color: #2b91af;">Subject</span>sub <span style="color: blue;">in</span> context.Subjects)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">SelectListItem</span> select = <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectListItem</span>() { <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> Text=sub.name,<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> Value=sub.id.ToString(),<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> Selected=sub.isselected.Value};<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> list.Add(select);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">SubjectListView</span> view = <span style="color: blue;">new</span><span style="color: #2b91af;">SubjectListView</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> view.Subjects = list; <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> View(view);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">HttpPost</span>]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> List(<span style="color: #2b91af;">IEnumerable</span><<span style="color: blue;">string</span>> SelectItems)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (SelectItems != <span style="color: blue;">null</span>)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> <span style="color: blue;">string</span>.Join(<span style="color: #a31515;">","</span>, SelectItems);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">else</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> <span style="color: #a31515;">"No vaues are selected"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><br /><div class="MsoNormal"><br /></div>Model<br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">SubjectListView</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">IEnumerable</span><<span style="color: blue;">string</span>> SelectItems { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">List</span><<span style="color: #2b91af;">SelectListItem</span>> Subjects { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><br /><div class="MsoNormal"><br /></div><div class="MsoNormal"><o:p><br /></o:p></div>Output<br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-PqdokM3yVkQek5a4N5m4uNRnC-TUhUwzD0Kdg1vvW_fn_TEuYkV10TZKQUMaAu2A1cYutxhyI5ru7guWD8tSQV0sXteWJNUNhOF_xFR237NqhcVWCwmVpFb3aRDnrBURfycHY6uBaf_W/s1600/listview.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-PqdokM3yVkQek5a4N5m4uNRnC-TUhUwzD0Kdg1vvW_fn_TEuYkV10TZKQUMaAu2A1cYutxhyI5ru7guWD8tSQV0sXteWJNUNhOF_xFR237NqhcVWCwmVpFb3aRDnrBURfycHY6uBaf_W/s1600/listview.png" /></a></div><br />When click on Submit post back output will be 2,3<br /><br /><br />From this article you can learn how to pass the value from the multi select values from the listbox to the postback.</div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com1tag:blogger.com,1999:blog-5150847477515676948.post-7936848662641366212014-01-01T00:55:00.000-08:002016-07-12T20:39:14.666-07:00Call a Editor Template - ASP.NET MVC<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<span style="color: #666666;"><br /></span>
<span style="color: #666666;"> In this article we are going to see how to call a Editor template from a view,Let we take an example of Area of interest survey form which have a sequence of subjects, where user have to select the subjects got interest. when they click submit the values are submitted to the page.</span><br />
<span style="color: #666666;"><br /></span>
<span style="color: #666666;">EditorFor Model() Method will call the view which have the same name of model type present in the Editor Template Folder.using ADO.Net Entity Framework imports the DataModel and save it as Subject for model name.</span><br />
<span style="color: #666666;"><br /></span>
<br />
<b><span style="color: red;">Output</span></b><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzXWYQnlTNOw6wIVQVvo_cAByE14Peq9-qwkJqihGCzXkgY0MbIQut8kI7k9kt827pbFmf77R-21TWkNKM7a3aBtTEilgQVdn8NR_sA9lidrAI_zQxqYCqAv0zh95DgsGb1ym7bcWIsNVR/s1600/area1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="213" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhzXWYQnlTNOw6wIVQVvo_cAByE14Peq9-qwkJqihGCzXkgY0MbIQut8kI7k9kt827pbFmf77R-21TWkNKM7a3aBtTEilgQVdn8NR_sA9lidrAI_zQxqYCqAv0zh95DgsGb1ym7bcWIsNVR/s320/area1.png" width="320" /></a></div>
<br />
<br />
<br />
<b><span style="color: red;">After Submit</span></b><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjBekL4cn1jnzhVDOR9_apqLCmTgjDWW37qfza_wYTnJBJUzBeOUZXSDKJhu4x8Xl1zUqYVKgcqg0Pnx6b2PvFgfRWPJfcoPS2lMjHwYOKV2SMGETXxig6TtAeqJ5JFB1wWMg3D8UiYx_E/s1600/area2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="45" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgjBekL4cn1jnzhVDOR9_apqLCmTgjDWW37qfza_wYTnJBJUzBeOUZXSDKJhu4x8Xl1zUqYVKgcqg0Pnx6b2PvFgfRWPJfcoPS2lMjHwYOKV2SMGETXxig6TtAeqJ5JFB1wWMg3D8UiYx_E/s320/area2.png" width="320" /></a></div>
<br />
<br />
<br />
<br />
Step 1 : Create a Controller name InfoController.<br />
Step 2 : Create a View with strongly typed IEnumerable<Subject> Index.cshtml, which is present under the folder of the View -> Info<br />
Step 3 : Create a View name it as Subject and save under the folder Editor Templates as Subject.cshtml<br />
Step 4 : Create a Get and Post requests.<br />
<br />
<br />
<br />
<b><span style="color: red;">Sql Script:</span></b><br />
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: "courier new"; font-size: 10.0pt;">create</span><span style="font-family: "courier new"; font-size: 10.0pt;"> <span style="color: blue;">table</span><span style="color: blue;">subject<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: "courier new"; font-size: 10.0pt;">(<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: "courier new"; font-size: 10.0pt;">id <span style="color: blue;">int</span> <span style="color: blue;">identity</span><span style="color: grey;">(</span>1<span style="color: grey;">,</span>1<span style="color: grey;">),<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: "courier new"; font-size: 10.0pt;">name <span style="color: blue;">varchar</span><span style="color: grey;">(</span>100<span style="color: grey;">),<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: "courier new"; font-size: 10.0pt;">isselected <span style="color: blue;">bit<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="font-family: "courier new"; font-size: 10.0pt;">)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: "courier new"; font-size: 10.0pt;">insert</span><span style="font-family: "courier new"; font-size: 10.0pt;"> <span style="color: blue;">into</span><span style="color: blue;">subject</span><span style="color: grey;">(</span>name<span style="color: grey;">,</span>isselected<span style="color: grey;">)<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: "courier new"; font-size: 10.0pt;">values</span><span style="font-family: "courier new"; font-size: 10.0pt;">(</span><span style="color: red; font-family: "courier new"; font-size: 10.0pt;">'Computer Science'</span><span style="font-family: "courier new"; font-size: 10.0pt;">,</span><span style="font-family: "courier new"; font-size: 10.0pt;">0<span style="color: grey;">)<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: "courier new"; font-size: 10.0pt;">insert</span><span style="font-family: "courier new"; font-size: 10.0pt;"> <span style="color: blue;">into</span><span style="color: blue;">subject</span><span style="color: grey;">(</span>name<span style="color: grey;">,</span>isselected<span style="color: grey;">)<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: "courier new"; font-size: 10.0pt;">values</span><span style="font-family: "courier new"; font-size: 10.0pt;">(</span><span style="color: red; font-family: "courier new"; font-size: 10.0pt;">'Micro Biology'</span><span style="font-family: "courier new"; font-size: 10.0pt;">,</span><span style="font-family: "courier new"; font-size: 10.0pt;">1<span style="color: grey;">)<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: "courier new"; font-size: 10.0pt;">insert</span><span style="font-family: "courier new"; font-size: 10.0pt;"> <span style="color: blue;">into</span><span style="color: blue;">subject</span><span style="color: grey;">(</span>name<span style="color: grey;">,</span>isselected<span style="color: grey;">)<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: "courier new"; font-size: 10.0pt;">values</span><span style="font-family: "courier new"; font-size: 10.0pt;">(</span><span style="color: red; font-family: "courier new"; font-size: 10.0pt;">'Electronics'</span><span style="font-family: "courier new"; font-size: 10.0pt;">,</span><span style="font-family: "courier new"; font-size: 10.0pt;">1<span style="color: grey;">)<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: "courier new"; font-size: 10.0pt;">insert</span><span style="font-family: "courier new"; font-size: 10.0pt;"> <span style="color: blue;">into</span><span style="color: blue;">subject</span><span style="color: grey;">(</span>name<span style="color: grey;">,</span>isselected<span style="color: grey;">)<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: "courier new"; font-size: 10.0pt;">values</span><span style="font-family: "courier new"; font-size: 10.0pt;">(</span><span style="color: red; font-family: "courier new"; font-size: 10.0pt;">'Civil'</span><span style="font-family: "courier new"; font-size: 10.0pt;">,</span><span style="font-family: "courier new"; font-size: 10.0pt;">0<span style="color: grey;">)<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<br /></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: "courier new"; font-size: 10.0pt;">insert</span><span style="font-family: "courier new"; font-size: 10.0pt;"> <span style="color: blue;">into</span><span style="color: blue;">subject</span><span style="color: grey;">(</span>name<span style="color: grey;">,</span>isselected<span style="color: grey;">)<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<span style="color: blue; font-family: "courier new"; font-size: 10.0pt;">values</span><span style="font-family: "courier new"; font-size: 10.0pt;">(</span><span style="color: red; font-family: "courier new"; font-size: 10.0pt;">'Aeronotics'</span><span style="font-family: "courier new"; font-size: 10.0pt;">,</span><span style="font-family: "courier new"; font-size: 10.0pt;">0<span style="color: grey;">)<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;">
<br /></div>
<span style="color: blue; font-family: "courier new"; font-size: 10.0pt;"> select</span><span style="font-family: "courier new"; font-size: 10.0pt;"> <span style="color: grey;">*</span><span style="color: blue;">from</span> <span style="color: blue;">subject</span></span><br />
<span style="font-family: "courier new"; font-size: 10.0pt;"><span style="color: blue;"><br /></span></span>
<span style="font-family: "courier new"; font-size: 10.0pt;"><span style="color: blue;"><br /></span></span>
<br />
<b><span style="color: orange;">C#:</span></b><br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="font-family: "consolas"; font-size: 9.5pt;"> System;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="font-family: "consolas"; font-size: 9.5pt;"> System.Collections.Generic;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="font-family: "consolas"; font-size: 9.5pt;"> System.Linq;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="font-family: "consolas"; font-size: 9.5pt;"> System.Web;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="font-family: "consolas"; font-size: 9.5pt;"> System.Web.Mvc;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="font-family: "consolas"; font-size: 9.5pt;"> EmpApp.Models;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="font-family: "consolas"; font-size: 9.5pt;"> System.Text;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">namespace</span><span style="font-family: "consolas"; font-size: 9.5pt;"> EmpApp.Controllers<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">StudiesController</span> : <span style="color: #2b91af;">Controller</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: #2b91af;">EmployeeContext</span> context = <span style="color: blue;">new</span>Models.<span style="color: #2b91af;">EmployeeContext</span>();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> [<span style="color: #2b91af;">HttpGet</span>]<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span>Index()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> { <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">return</span> View(context.Subjects.ToList());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> [<span style="color: #2b91af;">HttpPost</span>]<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> Index(<span style="color: #2b91af;">IEnumerable</span><<span style="color: #2b91af;">Subject</span>> subjects)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: #2b91af;">StringBuilder</span> builder = <span style="color: blue;">new</span><span style="color: #2b91af;">StringBuilder</span>();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> builder.Append(<span style="color: #a31515;">"Result : "</span>);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">if</span> (subjects.Count(x => x.isselected!=<span style="color: blue;">null</span>) > 0)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> builder.Append(<span style="color: #a31515;">" Selected Subjects are "</span>);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">foreach</span> (<span style="color: #2b91af;">Subject</span>sub <span style="color: blue;">in</span> subjects)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">if</span>(sub.isselected.Value)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> builder.Append(sub.name + <span style="color: #a31515;">", "</span>);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> builder.Remove(builder.ToString().LastIndexOf(<span style="color: #a31515;">","</span>), 1);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">else</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> builder.Append(<span style="color: #a31515;">" None of the subjects is selected"</span>);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">return</span> builder.ToString();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<br />
<div class="MsoNormal">
<br />
<br /></div>
<b><span style="color: orange;">View</span></b><br />
<b><span style="color: red;">Subject.cshtml</span></b><br />
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: yellow; font-family: "consolas"; font-size: 9.5pt;">@model </span><span style="font-family: "consolas"; font-size: 9.5pt;">EmpApp.Models.<span style="color: #2b91af;">Subject</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: yellow; font-family: "consolas"; font-size: 9.5pt;">@</span><span style="font-family: "consolas"; font-size: 9.5pt;">Html.HiddenFor(m=>m.id)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: yellow; font-family: "consolas"; font-size: 9.5pt;">@</span><span style="font-family: "consolas"; font-size: 9.5pt;">Html.HiddenFor(m=>m.name)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: yellow; font-family: "consolas"; font-size: 9.5pt;">@</span><span style="font-family: "consolas"; font-size: 9.5pt;">Html.HiddenFor(m=>m.isselected)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: yellow; font-family: "consolas"; font-size: 9.5pt;">@</span><span style="font-family: "consolas"; font-size: 9.5pt;">Html.CheckBoxFor(m=>m.isselected.Value)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: yellow; font-family: "consolas"; font-size: 9.5pt;">@</span><span style="font-family: "consolas"; font-size: 9.5pt;">Html.DisplayFor(m=>m.name)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: "consolas"; font-size: 9.5pt;">br</span><span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">/><o:p></o:p></span></span></div>
<br />
<div class="MsoNormal">
<br />
<br />
<br /></div>
<br />
<b><span style="color: red;">Index.cshtml</span></b><br />
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: yellow; font-family: "consolas"; font-size: 9.5pt;">@model </span><span style="color: #2b91af; font-family: "consolas"; font-size: 9.5pt;">IEnumerable</span><span style="font-family: "consolas"; font-size: 9.5pt;"><EmpApp.Models.<span style="color: #2b91af;">Subject</span>><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: yellow; font-family: "consolas"; font-size: 9.5pt;">@{</span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> ViewBag.Title = <span style="color: #a31515;">"Area of Interest"</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: yellow; font-family: "consolas"; font-size: 9.5pt;">}</span><span style="font-family: "consolas"; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: "consolas"; font-size: 9.5pt;">h2</span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">></span><span style="font-family: "consolas"; font-size: 9.5pt;">Area of Interest<span style="color: blue;"></</span><span style="color: maroon;">h2</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background: yellow; font-family: "consolas"; font-size: 9.5pt;">@</span><span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="font-family: "consolas"; font-size: 9.5pt;"> (Html.BeginForm())<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.EditorForModel()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">input</span> <span style="color: red;">type</span><span style="color: blue;">="submit"</span><span style="color: red;">value</span><span style="color: blue;">="Submit"</span><span style="color: blue;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;">}<o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin-left: .5in;">
<br /></div>
<div class="MsoNormal" style="margin-left: .5in;">
<span style="font-size: 10.0pt; line-height: 115%;"><br /></span></div>
<br />
<span style="color: #666666;"><br /></span>
<span style="color: #666666;">From this article you can learn how to call the Editor Template from the View and how to create a Editor template.</span><br />
<span style="color: #666666;"><br /></span>
<br />
<br /></div>
DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com1tag:blogger.com,1999:blog-5150847477515676948.post-89183729920212293222013-12-31T21:37:00.000-08:002016-07-12T20:42:36.083-07:00Generate XML from the Class Template<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7wjGMOx9yy1MrvOf92p4bpAClJU2Sl0GIHFugG0hkIfRbL3qhQHMmMX6d7cHh3GOigotQaXGsQfwlb2DZBgjr4IQbIP3Mx5lvdGzAP2K2mEAgzTsw_QcA6pj4fCZ4I2HwAUQzVSLG3B4X/s1600/C%2523.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="208" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7wjGMOx9yy1MrvOf92p4bpAClJU2Sl0GIHFugG0hkIfRbL3qhQHMmMX6d7cHh3GOigotQaXGsQfwlb2DZBgjr4IQbIP3Mx5lvdGzAP2K2mEAgzTsw_QcA6pj4fCZ4I2HwAUQzVSLG3B4X/s640/C%2523.png" width="640" /></a></div>
<br />
<br />
<br />
<span style="color: #666666;">In this post we are going to see how to generate the xml file from a template class. To generate the xml file from the class we have to specify the class as serialize and column as xml attribute to generate the values as attribute in xml file.</span><br />
<span style="color: #666666;"><br /></span>
<span style="color: #666666;"><br /></span>
<span style="color: #666666;"><br /></span>
<br />
<b><span style="color: red;">output:</span></b><br />
<br />
<div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;">
<span style="color: #494949; font-family: "consolas"; font-size: 10.0pt;"><?</span><span style="color: #9b703f; font-family: "consolas"; font-size: 10.0pt;">xml</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">version</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"1.0"</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">encoding</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"utf-8"</span><span style="color: #494949; font-family: "consolas"; font-size: 10.0pt;">?></span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;">
<span style="color: #9b703f; font-family: "consolas"; font-size: 10.0pt;"><PeopleInfo</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">xmlns:xsi</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"http://www.w3.org/2001/XMLSchema-instance"</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">xmlns:xsd</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"http://www.w3.org/2001/XMLSchema"</span><span style="color: #9b703f; font-family: "consolas"; font-size: 10.0pt;">></span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;">
<span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #9b703f; font-family: "consolas"; font-size: 10.0pt;"><Peoples></span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;">
<span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #9b703f; font-family: "consolas"; font-size: 10.0pt;"><Person</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">Name</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"Rajesh"</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">Email</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"rajhseg@gmail.com"</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">StreetAddress</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"R.E St"</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">AdditionNotes</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"Notes 1"</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">Birthday</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"2002-01-01T11:01:08.3657823+05:30"</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #9b703f; font-family: "consolas"; font-size: 10.0pt;">/></span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;">
<span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #9b703f; font-family: "consolas"; font-size: 10.0pt;"><Person</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">Name</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"Suresh"</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">Email</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"sdsfs@gmail.com"</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">StreetAddress</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"RG St"</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">AdditionNotes</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"Notes 2"</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">Birthday</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"1990-01-01T11:01:08.3667824+05:30"</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #9b703f; font-family: "consolas"; font-size: 10.0pt;">/></span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;">
<span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #9b703f; font-family: "consolas"; font-size: 10.0pt;"><Person</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">Name</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"Krish"</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">Email</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"krisg@gmail.com"</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">StreetAddress</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"GW St"</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">AdditionNotes</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"Notes 3"</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;">Birthday</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;">=</span><span style="color: #8f9d6a; font-family: "consolas"; font-size: 10.0pt;">"1992-01-01T11:01:08.3667824+05:30"</span><span style="color: #f8f8f8; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #9b703f; font-family: "consolas"; font-size: 10.0pt;">/></span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;">
<span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;"> </span><span style="color: #9b703f; font-family: "consolas"; font-size: 10.0pt;"></Peoples></span><span style="color: #cccccc; font-family: "consolas"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background-color: #141414; background-position: initial initial; background-repeat: initial initial; margin-bottom: 0.0001pt;">
<span style="color: #9b703f; font-family: "consolas"; font-size: 10.0pt;"></PeopleInfo></span><span style="font-family: "times new roman" , "serif"; font-size: 12.0pt;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal">
<br />
<br /></div>
<div class="MsoNormal">
<span style="font-size: 10.0pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal">
<span style="font-size: 10.0pt; line-height: 115%;"><b><span style="color: red;">C#:</span></b></span></div>
<div class="MsoNormal">
<span style="font-size: 10.0pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="font-family: "consolas"; font-size: 9.5pt;"> System;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="font-family: "consolas"; font-size: 9.5pt;"> System.Collections.Generic;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="font-family: "consolas"; font-size: 9.5pt;"> System.Linq;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="font-family: "consolas"; font-size: 9.5pt;"> System.Text;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="font-family: "consolas"; font-size: 9.5pt;"> System.Xml.Serialization;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">using</span><span style="font-family: "consolas"; font-size: 9.5pt;"> System.IO;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: "consolas"; font-size: 9.5pt;">namespace</span><span style="font-family: "consolas"; font-size: 9.5pt;"> ConsoleApplication1<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> [<span style="color: #2b91af;">Serializable</span>]<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Person</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> [<span style="color: #2b91af;">XmlAttribute</span>]<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> Name<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">get</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">set</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> [<span style="color: #2b91af;">XmlAttribute</span>]<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> Email<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">get</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">set</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> [<span style="color: #2b91af;">XmlAttribute</span>]<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span>StreetAddress<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">get</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">set</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> [<span style="color: #2b91af;">XmlAttribute</span>]<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> AdditionNotes<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">get</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">set</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> [<span style="color: #2b91af;">XmlAttribute</span>]<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">DateTime</span>Birthday<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">get</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">set</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span><br />
<span style="font-family: "consolas"; font-size: 9.5pt;"><br /></span>
<span style="font-family: "consolas"; font-size: 9.5pt;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> [<span style="color: #2b91af;">Serializable</span>]<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">PeopleInfo</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> { <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">List</span><<span style="color: #2b91af;">Person</span>> Peoples { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">class</span> <span style="color: #2b91af;">Program</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: blue;">static</span> <span style="color: blue;">void</span> Main(<span style="color: blue;">string</span>[] args)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: #2b91af;">List</span><<span style="color: #2b91af;">Person</span>> Peoples = <span style="color: blue;">new</span> <span style="color: #2b91af;">List</span><<span style="color: #2b91af;">Person</span>>();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> Peoples.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">Person</span>() {Name=<span style="color: #a31515;">"Rajesh"</span>,Email=<span style="color: #a31515;">"rajhseg@gmail.com"</span>,</span><br />
<span style="font-family: "consolas"; font-size: 9.5pt;"> Birthday=<span style="color: #2b91af;">DateTime</span>.Now.AddYears(-12),</span><br />
<span style="font-family: "consolas"; font-size: 9.5pt;"> AdditionNotes=<span style="color: #a31515;">"Notes 1"</span>,StreetAddress=<span style="color: #a31515;">"R.E St"</span> });<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> Peoples.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">Person</span>() { Name = <span style="color: #a31515;">"Suresh"</span>, Email = <span style="color: #a31515;">"sdsfs@gmail.com"</span>, </span><br />
<span style="font-family: "consolas"; font-size: 9.5pt;"> Birthday = <span style="color: #2b91af;">DateTime</span>.Now.AddYears(-24), </span><br />
<span style="font-family: "consolas"; font-size: 9.5pt;"> AdditionNotes = <span style="color: #a31515;">"Notes 2"</span>, StreetAddress = <span style="color: #a31515;">"RG St"</span> });<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> Peoples.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">Person</span>() { Name = <span style="color: #a31515;">"Krish"</span>, Email = <span style="color: #a31515;">"krisg@gmail.com"</span>, </span><br />
<span style="font-family: "consolas"; font-size: 9.5pt;"> Birthday = <span style="color: #2b91af;">DateTime</span>.Now.AddYears(-22), AdditionNotes = <span style="color: #a31515;">"Notes 3"</span>, </span><br />
<span style="font-family: "consolas"; font-size: 9.5pt;"> StreetAddress = <span style="color: #a31515;">"GW St"</span> });<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: #2b91af;">PeopleInfo</span> ert = <span style="color: blue;">new</span><span style="color: #2b91af;">PeopleInfo</span>() { Peoples = Peoples};<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: #2b91af;">XmlSerializer</span> serialize = <span style="color: blue;">new</span><span style="color: #2b91af;">XmlSerializer</span>(<span style="color: blue;">typeof</span>(<span style="color: #2b91af;">PeopleInfo</span>));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: #2b91af;">TextWriter</span> writer = <span style="color: blue;">new</span><span style="color: #2b91af;">StreamWriter</span>(<span style="color: #a31515;">@"D:\sample.xml"</span>, <span style="color: blue;">true</span>);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> serialize.Serialize(writer, ert);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> <span style="color: #2b91af;">Console</span>.Read();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "consolas"; font-size: 9.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal">
</div>
<div class="MsoNormal">
<br />
<span style="color: #666666;"><br /></span></div>
<div class="MsoNormal">
<span style="color: #666666;">In this post you can learn how to generate xml file from a class template.</span><br />
<br />
<br />
<br /></div>
</div>
DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-22065244639203963672013-12-30T05:28:00.000-08:002014-01-10T22:03:55.239-08:00View Engines Present in ASP.NET MVC<div dir="ltr" style="text-align: left;" trbidi="on">In this article we are going to see number of view engines present in the MVC. There are two types of View Engine<br /><br />1. Razor View Engine<br />2 .Aspx View Engine<br /><br />In Razor<br /><br /><ul style="text-align: left;"><li>Code can be done by start of @ </li><li>vb and cs file are in the extension of cshtml and vbhtml</li></ul><div>In Aspx</div><div><br /></div><div><ul style="text-align: left;"><li>Code should be in between the <%: %></li><li>vb and cs file are in the same extension .aspx</li></ul><div>In the project we can have both aspx and razor view files,We can also use third party view engines.</div></div></div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-91661238515865863292013-12-30T05:11:00.000-08:002014-01-10T22:03:55.405-08:00Map a MetadataType to the Entity Framework Model - ASP.NET MVC<div dir="ltr" style="text-align: left;" trbidi="on">In this article we are going to see how to map a MetadataType to the Model class for applying the additonal rules and conditions.In the following samples we are created the model using entity framework.<br /><br />Model created by EntityFramwork :<br /><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;">[<span style="color: #2b91af;">EdmEntityTypeAttribute</span>(NamespaceName=<span style="color: #a31515;">"EmployeeModel"</span>, Name=<span style="color: #a31515;">"Department"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Serializable</span>()]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">DataContractAttribute</span>(IsReference=<span style="color: blue;">true</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Department</span> : <span style="color: #2b91af;">EntityObject</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> #region</span><span style="font-family: Consolas; font-size: 9.5pt;">Factory Method<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"><summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> Create a new Department object.</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"></summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"><param name="id"></span><span style="color: green;">Initial value of the ID property.</span><span style="color: grey;"></param></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: #2b91af;">Department</span> CreateDepartment(<span style="color: blue;">global</span>::System.<span style="color: #2b91af;">Int32</span>id)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Department</span> department = <span style="color: blue;">new</span><span style="color: #2b91af;">Department</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> department.ID = id;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> department;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> #endregion</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> #region</span><span style="font-family: Consolas; font-size: 9.5pt;">Primitive Properties<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"><summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> No Metadata Documentation available.</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"></summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">EdmScalarPropertyAttribute</span>(EntityKeyProperty=<span style="color: blue;">true</span>, IsNullable=<span style="color: blue;">false</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">DataMemberAttribute</span>()]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">global</span>::System.<span style="color: #2b91af;">Int32</span> ID<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">get</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> _ID;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">set</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (_ID != <span style="color: blue;">value</span>)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> OnIDChanging(<span style="color: blue;">value</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ReportPropertyChanging(<span style="color: #a31515;">"ID"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> _ID = <span style="color: #2b91af;">StructuralObject</span>.SetValidValue(<span style="color: blue;">value</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ReportPropertyChanged(<span style="color: #a31515;">"ID"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> OnIDChanged();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> <span style="color: blue;">global</span>::System.<span style="color: #2b91af;">Int32</span> _ID;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">partial</span> <span style="color: blue;">void</span>OnIDChanging(<span style="color: blue;">global</span>::System.<span style="color: #2b91af;">Int32</span> value);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">partial</span> <span style="color: blue;">void</span>OnIDChanged();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"><summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> No Metadata Documentation available.</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"></summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">EdmScalarPropertyAttribute</span>(EntityKeyProperty=<span style="color: blue;">false</span>, IsNullable=<span style="color: blue;">true</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">DataMemberAttribute</span>()]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">global</span>::System.<span style="color: #2b91af;">String</span> NAME<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">get</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> _NAME;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">set</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> OnNAMEChanging(<span style="color: blue;">value</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ReportPropertyChanging(<span style="color: #a31515;">"NAME"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> _NAME = <span style="color: #2b91af;">StructuralObject</span>.SetValidValue(<span style="color: blue;">value</span>, <span style="color: blue;">true</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ReportPropertyChanged(<span style="color: #a31515;">"NAME"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> OnNAMEChanged();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> <span style="color: blue;">global</span>::System.<span style="color: #2b91af;">String</span> _NAME;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">partial</span> <span style="color: blue;">void</span>OnNAMEChanging(<span style="color: blue;">global</span>::System.<span style="color: #2b91af;">String</span> value);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">partial</span> <span style="color: blue;">void</span>OnNAMEChanged();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> #endregion</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> #region</span><span style="font-family: Consolas; font-size: 9.5pt;">Navigation Properties<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"><summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> No Metadata Documentation available.</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><span style="color: grey;"></summary></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">XmlIgnoreAttribute</span>()]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">SoapIgnoreAttribute</span>()]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">DataMemberAttribute</span>()]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">EdmRelationshipNavigationPropertyAttribute</span>(<span style="color: #a31515;">"EmployeeModel"</span>, <span style="color: #a31515;">"FK__EMPTABLE__DEPTID__1A14E395"</span>, <span style="color: #a31515;">"EMPTABLE"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">EntityCollection</span><<span style="color: #2b91af;">Employee</span>> Employees<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">get</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> ((<span style="color: #2b91af;">IEntityWithRelationships</span>)<span style="color: blue;">this</span>).RelationshipManager.GetRelatedCollection<<span style="color: #2b91af;">Employee</span>>(<span style="color: #a31515;">"EmployeeModel.FK__EMPTABLE__DEPTID__1A14E395"</span>, <span style="color: #a31515;">"EMPTABLE"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">set</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> ((<span style="color: blue;">value</span>!= <span style="color: blue;">null</span>))<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ((<span style="color: #2b91af;">IEntityWithRelationships</span>)<span style="color: blue;">this</span>).RelationshipManager.InitializeRelatedCollection<<span style="color: #2b91af;">Employee</span>>(<span style="color: #a31515;">"EmployeeModel.FK__EMPTABLE__DEPTID__1A14E395"</span>, <span style="color: #a31515;">"EMPTABLE"</span>, <span style="color: blue;">value</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> #endregion</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><br /><div class="MsoNormal"><br /></div>MetadataType:<br /><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;">[<span style="color: #2b91af;">MetadataType</span>(<span style="color: blue;">typeof</span>(<span style="color: #2b91af;">DepartmentMetadata</span>))]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Department</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">DepartmentMetadata</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Display</span>(Name=<span style="color: #a31515;">"Department Name"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> NAME { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><br /><div class="MsoNormal"><br /></div><div class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%;"><br /></span></div>In this we need to change the display name of a Property, so we can see how to do this .<br /><br /><br /><br />HTML :<br /><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@model </span><span style="font-family: Consolas; font-size: 9.5pt;">EmpApp.Models.<span style="color: #2b91af;">Employee</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@{</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> ViewBag.Title = <span style="color: #a31515;">"Details"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">}</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">h2</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;">Details<span style="color: blue;"></</span><span style="color: maroon;">h2</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">fieldset</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">legend</span><span style="color: blue;">></span>Employee<span style="color: blue;"></</span><span style="color: maroon;">legend</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="display-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DisplayNameFor(model => model.NAME)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="display-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DisplayFor(model => model.NAME)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="display-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DisplayNameFor(model => model.Department.NAME)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="display-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DisplayFor(model => model.Department.NAME)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="display-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DisplayNameFor(model => model.COUNTRY)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="display-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DisplayFor(model => model.COUNTRY)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="display-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DisplayNameFor(model => model.MARRIED)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="display-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DisplayFor(model => model.MARRIED)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">fieldset</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">p</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ActionLink(<span style="color: #a31515;">"Edit"</span>, <span style="color: #a31515;">"Edit"</span>, <span style="color: blue;">new</span> { id=Model.ID }) |<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ActionLink(<span style="color: #a31515;">"Back to List"</span>, <span style="color: #a31515;">"Index"</span>)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">p</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><br /><div class="MsoNormal"><br /></div><br /><br /><br /><br /></div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-49590188086994757052013-12-29T19:34:00.000-08:002014-01-10T22:03:55.278-08:00Bind a Model for form post using interface - ASP.NET MVC<div dir="ltr" style="text-align: left;" trbidi="on"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7wjGMOx9yy1MrvOf92p4bpAClJU2Sl0GIHFugG0hkIfRbL3qhQHMmMX6d7cHh3GOigotQaXGsQfwlb2DZBgjr4IQbIP3Mx5lvdGzAP2K2mEAgzTsw_QcA6pj4fCZ4I2HwAUQzVSLG3B4X/s1600/C%2523.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7wjGMOx9yy1MrvOf92p4bpAClJU2Sl0GIHFugG0hkIfRbL3qhQHMmMX6d7cHh3GOigotQaXGsQfwlb2DZBgjr4IQbIP3Mx5lvdGzAP2K2mEAgzTsw_QcA6pj4fCZ4I2HwAUQzVSLG3B4X/s1600/C%2523.png" /></a></div><br /><br />In this article we are going to see how to bind a model values from the form post , by ignore the exclude properties for binding.<br /><br />By passing the Interface type in update model ,it will update the particular properties which are present in Interface to the object<br /><br /><b><span style="color: red; font-size: x-small;">Interface:</span></b><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">public</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">interface</span> <span style="color: #2b91af;">IEmployee</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">int</span> EmployeeId{<span style="color: blue;">set</span>;<span style="color: blue;">get</span>;}<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">string</span> Country { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">string</span> Married { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">int</span> DepartmentId { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"><br /></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"><br /></span></div><b><span style="color: red; font-size: x-small;">Employee Model:</span></b><br /><div><b><span style="color: red; font-size: x-small;"><br /></span></b></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Table</span>(<span style="color: #a31515;">"EMPTABLE"</span>)]</span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Employee</span>:<span style="color: #2b91af;">IEmployee</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Column</span>(<span style="color: #a31515;">"ID"</span>)] <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">int</span> EmployeeId { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Column</span>(<span style="color: #a31515;">"NAME"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Required</span>(ErrorMessage=<span style="color: #a31515;">"Please Fill Employee Name"</span>)] <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span>EmployeeName { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Column</span>(<span style="color: #a31515;">"COUNTRY"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Required</span>(ErrorMessage=<span style="color: #a31515;">"Please Fill the Country"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> Country { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Column</span>(<span style="color: #a31515;">"MARRIED"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Required</span>(ErrorMessage=<span style="color: #a31515;">"Please Specify the Married y/n"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> Married { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Column</span>(<span style="color: #a31515;">"DEPTID"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Required</span>(ErrorMessage=<span style="color: #a31515;">"Please specify the Department"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">int</span>DepartmentId { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><br /><div class="MsoNormal"><br /></div><br /><span style="color: red; font-size: x-small;"><b>C#:</b></span><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">HttpPost</span>]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">ActionName</span>(<span style="color: #a31515;">"Edit"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span>Edit_Post(<span style="color: blue;">int</span> employeeId)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Employee</span> emp = (<span style="color: blue;">new</span><span style="color: #2b91af;">EmployeeDbContext</span>()).Employees.Single(x => x.EmployeeId == employeeId);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> TryUpdateModel<<span style="color: #2b91af;">IEmployee</span>>(emp);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (ModelState.IsValid)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">BusLayer</span> bl = <span style="color: blue;">new</span> <span style="color: #2b91af;">BusLayer</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> bl.Update(emp);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> RedirectToAction(<span style="color: #a31515;">"Details"</span>, <span style="color: blue;">new</span>{ id=emp.DepartmentId});<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> View(emp);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><br /><div class="MsoNormal"><br /></div><br /><br />From this article you can learn how to bind the model values from the form post using the interface. which will help to ignore the unwanted values to bind in form post.<br /><br /></div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-85788640782731031182013-12-29T19:14:00.000-08:002014-01-10T22:03:55.382-08:00Play a Video File from the Web - ASP.NET<div dir="ltr" style="text-align: left;" trbidi="on">In this article we are going to see how to play a video file from the web or offline, for this we are creating a application which will take the input in from the text and Play the file.<br /><br />We are creating a Literal control and assign the object value at run time while play.<br /><br /><b><span style="color: red;">HTML:</span></b><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">form</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">id</span><span style="color: blue;">="form1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">literal</span> <span style="color: red;">id</span><span style="color: blue;">="Literal1"</span><span style="color: red;">runat</span><span style="color: blue;">="server"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">literal</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">textbox</span> <span style="color: red;">id</span><span style="color: blue;">="InputText"</span><span style="color: red;">runat</span><span style="color: blue;">="server"</span><span style="color: red;">width</span><span style="color: blue;">="500px"</span><span style="color: red;">height</span><span style="color: blue;">="50px"</span><span style="color: red;">wrap</span><span style="color: blue;">="true"</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">textmode</span><span style="color: blue;">="multiLine"</span><span style="color: red;">readonly</span><span style="color: blue;">="false"</span><span style="color: blue;">></span>http://localhost:30687/Harivarasanam.mp4<span style="color: blue;"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">textbox</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">button</span> <span style="color: red;">id</span><span style="color: blue;">="Button1"</span><span style="color: red;">runat</span><span style="color: blue;">="server"</span><span style="color: red;">text</span><span style="color: blue;">="Play"</span><span style="color: red;">onclick</span><span style="color: blue;">="Button1_Click"</span><span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">form</span><span style="color: blue;">><o:p></o:p></span></span></div><br /><div class="MsoNormal"><br /></div><br /><b><span style="color: red;">C# Code:</span></b><br /><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 10.0pt;">using</span><span style="font-family: Consolas; font-size: 10.0pt;"> System;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 10.0pt;">using</span><span style="font-family: Consolas; font-size: 10.0pt;"> System.Collections.Generic;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 10.0pt;">using</span><span style="font-family: Consolas; font-size: 10.0pt;"> System.Linq;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 10.0pt;">using</span><span style="font-family: Consolas; font-size: 10.0pt;"> System.Web;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 10.0pt;">using</span><span style="font-family: Consolas; font-size: 10.0pt;"> System.Web.UI;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 10.0pt;">using</span><span style="font-family: Consolas; font-size: 10.0pt;"> System.Web.UI.WebControls;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 10.0pt;">namespace</span><span style="font-family: Consolas; font-size: 10.0pt;"> WebApplication1<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;">{<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">public</span> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Player</span> : System.Web.UI.<span style="color: #2b91af;">Page</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">protected</span> <span style="color: blue;">void</span>Page_Load(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">protected</span> <span style="color: blue;">void</span>Button1_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">try</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">string</span> mySourceUrl = <span style="color: blue;">this</span>.InputText.Text;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">bool</span> isFullSize = <span style="color: blue;">false</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">this</span>.Literal1.Text = <span style="color: blue;">this</span>.GetWma(mySourceUrl, isFullSize);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">catch</span> (<span style="color: #2b91af;">Exception</span>ex)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">this</span>.Response.Write(ex.ToString());<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">private</span> <span style="color: blue;">string</span>GetWma(<span style="color: blue;">string</span> sourceUrl, <span style="color: blue;">bool</span> isFullSize)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">string</span> newtag = <span style="color: #a31515;">""</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> sourceUrl = sourceUrl + <span style="color: #a31515;">""</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> sourceUrl = sourceUrl.Trim();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">if</span> (sourceUrl.Length > 0)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">else</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">throw</span> <span style="color: blue;">new</span>System.<span style="color: #2b91af;">ArgumentNullException</span>(<span style="color: #a31515;">"sourceUrl"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">string</span> myWidthAndHeight = <span style="color: #a31515;">""</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">if</span> (isFullSize)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> myWidthAndHeight = <span style="color: #a31515;">""</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">else</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> myWidthAndHeight = <span style="color: #a31515;">"width='640' height='480'"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> newtag = newtag + <span style="color: #a31515;">"<object classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' id='player' "</span> + myWidthAndHeight + <span style="color: #a31515;">" standby='Please wait while the object is loaded...'>"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> newtag = newtag + <span style="color: #a31515;">"<param name='url' value='"</span> + sourceUrl + <span style="color: #a31515;">"' />"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> newtag = newtag + <span style="color: #a31515;">"<param name='src' value='"</span> + sourceUrl + <span style="color: #a31515;">"' />"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> newtag = newtag + <span style="color: #a31515;">"<param name='AutoStart' value='true' />"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="color: green; font-family: Consolas; font-size: 10.0pt;">/* -100 is fully left, 100 is fully right. */</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 10.0pt;">newtag = newtag + <span style="color: #a31515;">"<param name='Balance' value='0' />"</span>; <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="color: green; font-family: Consolas; font-size: 10.0pt;">/* Position in seconds when starting. */</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 10.0pt;">newtag = newtag + <span style="color: #a31515;">"<param name='CurrentPosition' value='0' />"</span>; <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="color: green; font-family: Consolas; font-size: 10.0pt;">/* Show play/stop/pause controls. */</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: 0.5in;"><span style="font-family: Consolas; font-size: 10.0pt;"> newtag = newtag + <span style="color: #a31515;">"<param name='showcontrols' value='true' />"</span>; <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="color: green; font-family: Consolas; font-size: 10.0pt;">/* Allow right-click. */</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 10.0pt;">newtag = newtag + <span style="color: #a31515;">"<param name='enablecontextmenu' value='true' />"</span>; <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in; text-indent: 0.5in;"><span style="color: green; font-family: Consolas; font-size: 10.0pt;">/* Start in full screen or not. */</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> newtag = newtag + <span style="color: #a31515;">"<param name='fullscreen' value='"</span> + </span><span style="font-family: Consolas; font-size: 10pt;">isFullSize.ToString() + </span><span style="color: #a31515; font-family: Consolas; font-size: 10pt;">"' />"</span><span style="font-family: Consolas; font-size: 10pt;">; </span><span style="font-family: Consolas; font-size: 10pt;"> </span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10pt;"><br /></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> newtag = newtag + <span style="color: #a31515;">"<param name='mute' value='false' />"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 10.0pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="color: green; font-family: Consolas; font-size: 10.0pt;">/* Number of times the content will play.*/</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 10.0pt;"> newtag = newtag + <span style="color: #a31515;">"<param name='PlayCount' value='1' />"</span>; <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="color: green; font-family: Consolas; font-size: 10.0pt;">/* 0.5=Slow, 1.0=Normal, 2.0=Fast*/</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 10.0pt;">newtag = newtag + <span style="color: #a31515;">"<param name='rate' value='1.0' />"</span>; <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="color: green; font-family: Consolas; font-size: 10.0pt;">/* full, mini, custom, none, invisible */</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 10.0pt;">newtag = newtag + <span style="color: #a31515;">"<param name='uimode' value='full' />"</span>; <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="color: green; font-family: Consolas; font-size: 10.0pt;">/* Show or hide the name of the file.*/</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 10.0pt;">newtag = newtag + <span style="color: #a31515;">"<param name='showdisplay' value='true' />"</span>; <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="color: green; font-family: Consolas; font-size: 10.0pt;">/* 0=lowest, 100=highest */</span><span style="font-family: Consolas; font-size: 10.0pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 10.0pt;">newtag = newtag + <span style="color: #a31515;">"<param name='volume' value='50' />"</span>; <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 1in;"><span style="font-family: Consolas; font-size: 10.0pt;">newtag = newtag + <span style="color: #a31515;">"</object>"</span>;</span><span style="font-family: Consolas; font-size: 10pt;"> </span><span style="font-family: Consolas; font-size: 10pt;"> </span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> <span style="color: blue;">return</span> newtag;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 10.0pt;">}<o:p></o:p></span></div><br /><div class="MsoNormal"><br /></div><div class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%;"><b><span style="color: red;">Output:</span></b></span></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKWkS8Cz89e8wzJIVNrxl5z24N29fubG6HoQ3CAOZsaKU6JaS-WtxojQKN2pYkdsfroAMpDWAl2EBnWw4SnSVVqq8nWd9LpzGIfjhCfWwCzNBAo-ODmw4QmjwDQViqXUse0VXRmz9vdt6q/s1600/Player1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgKWkS8Cz89e8wzJIVNrxl5z24N29fubG6HoQ3CAOZsaKU6JaS-WtxojQKN2pYkdsfroAMpDWAl2EBnWw4SnSVVqq8nWd9LpzGIfjhCfWwCzNBAo-ODmw4QmjwDQViqXUse0VXRmz9vdt6q/s1600/Player1.png" /></a></div><div class="MsoNormal"><span style="font-size: 10.0pt; line-height: 115%;"><br /></span></div><br /><b><span style="color: red;">After Play</span></b><br /><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTkU96polOrtFk1gn8oQMKDajiGdV2vctp9w1k4Tqi6NtdzxEIcTl_DJxgWZBNIp701NeLWKMitP5GsXEI3kgV3RlukYkwPBg0yuboVNnE1Lcgh1BeKHsL1j4-faxSEmxpK56ykiyyTqMu/s1600/Player2.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTkU96polOrtFk1gn8oQMKDajiGdV2vctp9w1k4Tqi6NtdzxEIcTl_DJxgWZBNIp701NeLWKMitP5GsXEI3kgV3RlukYkwPBg0yuboVNnE1Lcgh1BeKHsL1j4-faxSEmxpK56ykiyyTqMu/s1600/Player2.png" /></a></div><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />From this article we can see how to play a video file from web or from the offline.</div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-87736924773657514102013-12-29T18:16:00.000-08:002014-01-10T22:03:55.387-08:00How to Exclude or Include the properties of Model while Binding in Form POST - ASP.NET MVC<div dir="ltr" style="text-align: left;" trbidi="on"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7wjGMOx9yy1MrvOf92p4bpAClJU2Sl0GIHFugG0hkIfRbL3qhQHMmMX6d7cHh3GOigotQaXGsQfwlb2DZBgjr4IQbIP3Mx5lvdGzAP2K2mEAgzTsw_QcA6pj4fCZ4I2HwAUQzVSLG3B4X/s1600/C%2523.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7wjGMOx9yy1MrvOf92p4bpAClJU2Sl0GIHFugG0hkIfRbL3qhQHMmMX6d7cHh3GOigotQaXGsQfwlb2DZBgjr4IQbIP3Mx5lvdGzAP2K2mEAgzTsw_QcA6pj4fCZ4I2HwAUQzVSLG3B4X/s1600/C%2523.png" /></a></div><br /><br />In this article we are going to see how to Exclude or Include the Properties of Model while binding in form post, actually what is the need for explicit specify the properties to bind ? When we send a POST from the form it will bind the all values from the user request , so there is a scenario user can change the value of a read only value in POST Request , then the model will have a impact of changed one, To avoid this kind of things we are explicitly saying that thing kind of properties can be include or exclude from binding using a Attribute called Bind in the parameter.<br /><br />Inside the Bind attribute we can pass the parameters Include , Exclude with value as string , Properties can be specify by the comma separated. while binding as parameter in the method we have to specify the control name, but for the Bind we have to specify the Property name of the Model.<br /><br /><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">HttpPost</span>]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">ActionName</span>(<span style="color: #a31515;">"Edit"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span>Edit_Post([<span style="color: #2b91af;">Bind</span>(Exclude = <span style="color: #a31515;">"Name"</span>, Include = <span style="color: #a31515;">"EmployeeId,Country,Married,DepartmentId"</span>)]<span style="color: #2b91af;">Employee</span> emp)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> emp.EmployeeName = (<span style="color: blue;">new</span> <span style="color: #2b91af;">EmployeeDbContext</span>()).Employees.Single(x=>x.EmployeeId==emp.EmployeeId).EmployeeName;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (ModelState.IsValid)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">BusLayer</span> bl = <span style="color: blue;">new</span> <span style="color: #2b91af;">BusLayer</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> bl.Update(emp);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> RedirectToAction(<span style="color: #a31515;">"Details"</span>, <span style="color: blue;">new</span>{ id=emp.DepartmentId});<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> View(emp);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><br /><div class="MsoNormal"><br /></div><br /><br />From this article we can see how the values from the Form post are bind to the model instance of the input.<br /><br /><br /></div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com1tag:blogger.com,1999:blog-5150847477515676948.post-51173605667704735832013-12-29T17:55:00.000-08:002014-01-10T22:03:55.281-08:00How to Get the Difference between the Two Days<div dir="ltr" style="text-align: left;" trbidi="on"><br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7wjGMOx9yy1MrvOf92p4bpAClJU2Sl0GIHFugG0hkIfRbL3qhQHMmMX6d7cHh3GOigotQaXGsQfwlb2DZBgjr4IQbIP3Mx5lvdGzAP2K2mEAgzTsw_QcA6pj4fCZ4I2HwAUQzVSLG3B4X/s1600/C%2523.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7wjGMOx9yy1MrvOf92p4bpAClJU2Sl0GIHFugG0hkIfRbL3qhQHMmMX6d7cHh3GOigotQaXGsQfwlb2DZBgjr4IQbIP3Mx5lvdGzAP2K2mEAgzTsw_QcA6pj4fCZ4I2HwAUQzVSLG3B4X/s1600/C%2523.png" /></a></div>In this post we can see how to get the difference between the two dates<br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">DateTime</span><span style="font-family: Consolas; font-size: 9.5pt;"> dt1 = <span style="color: #2b91af;">DateTime</span>.Now;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">DateTime</span> dt2 = <span style="color: #2b91af;">DateTime</span>.Now.AddDays(3).AddSeconds(34);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> System.Threading.<span style="color: #2b91af;">Thread</span>.Sleep(4000);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">TimeSpan</span> span = dt2 - dt1;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Console</span>.WriteLine(<span style="color: #a31515;">" Days: "</span> + span.Days +<span style="color: #a31515;">" Min: "</span>+span.Minutes+<span style="color: #a31515;">" Sec: "</span>+span.Seconds);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Console</span>.Read();<o:p></o:p></span></div><br /><div class="MsoNormal"><br /></div><div class="MsoNormal"><o:p><br /></o:p></div><div class="MsoNormal"><o:p><b><span style="color: red;">Output:</span></b></o:p></div><div class="MsoNormal"><o:p><br /></o:p></div><div class="MsoNormal"><o:p>Days: 3 Min: 0 Sec: 34</o:p></div><div class="MsoNormal"><o:p><br /></o:p></div><div class="MsoNormal"><o:p><br /></o:p></div><div class="MsoNormal">Add the Span to the Date:</div><div class="MsoNormal"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">DateTime</span><span style="font-family: Consolas; font-size: 9.5pt;"> Sample = <span style="color: #2b91af;">DateTime</span>.Now.AddDays(4);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> Sample.Add(span);<o:p></o:p></span></div><div class="MsoNormal"></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><o:p><br /></o:p></div><div class="MsoNormal"><o:p>From this post you can learn how to add the date and difference between the dates.</o:p></div></div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-38776161995708402013-12-29T08:44:00.000-08:002014-01-10T22:03:55.259-08:00Update the Selected Properties of the Model in Form Post ASP.NET MVC<div dir="ltr" style="text-align: left;" trbidi="on">In this article we are going to see how to update the Model of selected properties in the Form Post , For that we have to understand about UpdateModel method, this method is used to update the model type variable value with the form post value. When there is a null value in the required column then the error will raise to avoid error, try to use the TryUpdateModel in this method when validate the posted value if any model validation error is there then it will return false.<br /><br />Try to use ModelState.IsValid property to check that the Model doesn't have any validation error.There is a second parameter in which series of string array parameter can be passed which specifies the property names.<br /><br /><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"><b><span style="color: red;"> Controller:</span></b></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"><br /></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">HttpGet</span>]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">ActionName</span>(<span style="color: #a31515;">"Edit"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span>Edit_Get(<span style="color: blue;">int</span> id)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Employee</span> emp = (<span style="color: blue;">new</span><span style="color: #2b91af;">EmployeeDbContext</span>()).Employees.Where(x => x.EmployeeId == id).FirstOrDefault();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> View(emp);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">HttpPost</span>]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">ActionName</span>(<span style="color: #a31515;">"Edit"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span>Edit_Post(<span style="color: blue;">int</span> id)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Employee</span> emp = (<span style="color: blue;">new</span><span style="color: #2b91af;">EmployeeDbContext</span>()).Employees.Single(x=>x.EmployeeId==id);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> TryUpdateModel(emp,<span style="color: blue;">new</span> <span style="color: blue;">string</span>[]{<span style="color: #a31515;">"Country"</span>,<span style="color: #a31515;">"Married"</span>,<span style="color: #a31515;">"DepartmentId"</span>});<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (ModelState.IsValid)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">BusLayer</span> bl = <span style="color: blue;">new</span> <span style="color: #2b91af;">BusLayer</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> bl.Update(emp);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> RedirectToAction(<span style="color: #a31515;">"Details"</span>, <span style="color: blue;">new</span>{ id=emp.DepartmentId});<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> View(emp);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><b><span style="color: red;">Model:</span></b></div><div class="MsoNormal"><b><span style="color: red;"><br /></span></b></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;">[<span style="color: #2b91af;">Table</span>(<span style="color: #a31515;">"EMPTABLE"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Employee</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Column</span>(<span style="color: #a31515;">"ID"</span>)] <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">int</span> EmployeeId { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Column</span>(<span style="color: #a31515;">"NAME"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Required</span>(ErrorMessage=<span style="color: #a31515;">"Please Fill Employee Name"</span>)] <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span>EmployeeName { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Column</span>(<span style="color: #a31515;">"COUNTRY"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Required</span>(ErrorMessage=<span style="color: #a31515;">"Please Fill the Country"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> Country { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Column</span>(<span style="color: #a31515;">"MARRIED"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Required</span>(ErrorMessage=<span style="color: #a31515;">"Please Specify the Married y/n"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">string</span> Married { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Column</span>(<span style="color: #a31515;">"DEPTID"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">Required</span>(ErrorMessage=<span style="color: #a31515;">"Please specify the Department"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">int</span>DepartmentId { <span style="color: blue;">set</span>; <span style="color: blue;">get</span>; }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><br /><div class="MsoNormal"><br /></div><div class="MsoNormal"><o:p><b><span style="color: red;">Business Layer:</span></b></o:p></div><div class="MsoNormal"><o:p><br /></o:p></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">public</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">class</span> <span style="color: #2b91af;">BusLayer</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">void</span> Update(<span style="color: #2b91af;">Employee</span> emp)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">SqlConnection</span> con = <span style="color: blue;">new</span><span style="color: #2b91af;">SqlConnection</span>(<span style="color: #2b91af;">ConfigurationManager</span>.ConnectionStrings[<span style="color: #a31515;">"EmployeeDbContext"</span>].ConnectionString);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> con.Open();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">try</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">SqlCommand</span> cmd = <span style="color: blue;">new</span> <span style="color: #2b91af;">SqlCommand</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.Connection = con;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.CommandType = System.Data.<span style="color: #2b91af;">CommandType</span>.StoredProcedure;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.CommandText = <span style="color: #a31515;">"EMP_Upd"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.Parameters.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">SqlParameter</span>(<span style="color: #a31515;">"@ID"</span>, emp.EmployeeId));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.Parameters.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">SqlParameter</span>(<span style="color: #a31515;">"@NAME"</span>, emp.EmployeeName));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.Parameters.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">SqlParameter</span>(<span style="color: #a31515;">"@DEPT"</span>, emp.DepartmentId));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.Parameters.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">SqlParameter</span>(<span style="color: #a31515;">"@COUNTRY"</span>, emp.Country));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.Parameters.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">SqlParameter</span>(<span style="color: #a31515;">"@MARRIED"</span>, emp.Married));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.ExecuteNonQuery();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">finally</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> con.Close();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">void</span> Create(<span style="color: blue;">string</span> name, <span style="color: blue;">string</span>country, <span style="color: blue;">string</span> married, <span style="color: blue;">int</span> departmentid)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">SqlConnection</span> con = <span style="color: blue;">new</span><span style="color: #2b91af;">SqlConnection</span>(<span style="color: #2b91af;">ConfigurationManager</span>.ConnectionStrings[<span style="color: #a31515;">"EmployeeDbContext"</span>].ConnectionString);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> con.Open();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">try</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">SqlCommand</span> cmd = <span style="color: blue;">new</span> <span style="color: #2b91af;">SqlCommand</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.Connection = con;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.CommandType = System.Data.<span style="color: #2b91af;">CommandType</span>.StoredProcedure;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.CommandText = <span style="color: #a31515;">"EMP_ADD"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.Parameters.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">SqlParameter</span>(<span style="color: #a31515;">"@NAME"</span>, name));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.Parameters.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">SqlParameter</span>(<span style="color: #a31515;">"@DEPT"</span>, departmentid));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.Parameters.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">SqlParameter</span>(<span style="color: #a31515;">"@COUNTRY"</span>, country));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.Parameters.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">SqlParameter</span>(<span style="color: #a31515;">"@MARRIED"</span>, married));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.ExecuteNonQuery();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">finally</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> con.Close();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal"><o:p> </o:p></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><o:p><br /></o:p></div>From this article you can learn how to bind the selected Model properties for submit from a Form.</div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-69158224729840978442013-12-29T07:13:00.000-08:002014-01-10T22:03:55.348-08:00Bind the Access DB to Gridview<div dir="ltr" style="text-align: left;" trbidi="on">From this Post we are going to see how to bind the access db to the gridview. For this we have to take the OleDbConnection as a connection.<br /><br /><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><span style="color: #2b91af; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><br /></span></div><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><span style="color: #2b91af; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><br /></span></div><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><span style="color: #2b91af; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">OleDbConnection</span><span style="font-family: Consolas; font-size: 10.5pt;"> myConnection = </span><span style="color: darkblue; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">default</span><span style="font-family: Consolas; font-size: 10.5pt;">(</span><span style="color: #2b91af; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">OleDbConnection</span><span style="font-family: Consolas; font-size: 10.5pt;">);<o:p></o:p></span></div><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><span style="font-family: Consolas; font-size: 10.5pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">OleDbCommand</span><span style="font-family: Consolas; font-size: 10.5pt;"> myCommand = </span><span style="color: darkblue; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">default</span><span style="font-family: Consolas; font-size: 10.5pt;">(</span><span style="color: #2b91af; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">OleDbCommand</span><span style="font-family: Consolas; font-size: 10.5pt;">);<o:p></o:p></span></div><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><span style="font-family: Consolas; font-size: 10.5pt;"> </span><span style="color: darkblue; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">string</span><span style="font-family: Consolas; font-size: 10.5pt;"> strSQL = </span><span style="color: darkblue; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">null</span><span style="font-family: Consolas; font-size: 10.5pt;">;<o:p></o:p></span></div><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><span style="font-family: Consolas; font-size: 10.5pt;"> strSQL = </span><span style="color: maroon; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"SELECT * FROM tblLogin "</span><span style="font-family: Consolas; font-size: 10.5pt;"> + </span><span style="color: maroon; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"WHERE username=rajesh"</span><span style="font-family: Consolas; font-size: 10.5pt; line-height: 13.5pt;">;</span></div><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><span style="font-family: Consolas; font-size: 10.5pt;"> myConnection = </span><span style="color: darkblue; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">new</span><span style="font-family: Consolas; font-size: 10.5pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">OleDbConnection</span><span style="font-family: Consolas; font-size: 10.5pt;">(</span><span style="color: maroon; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"Provider=Microsoft.Jet.OLEDB.4.0; "</span><span style="font-family: Consolas; font-size: 10.5pt;"> + </span><span style="color: maroon; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"Data Source="</span><span style="font-family: Consolas; font-size: 10.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><span style="font-family: Consolas; font-size: 10.5pt;"> + </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Server</span><span style="font-family: Consolas; font-size: 10.5pt;">.</span><span style="color: #2b91af; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">MapPath</span><span style="font-family: Consolas; font-size: 10.5pt;">(</span><span style="color: maroon; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"login.mdb"</span><span style="font-family: Consolas; font-size: 10.5pt;">) + </span><span style="color: maroon; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">";"</span><span style="font-family: Consolas; font-size: 10.5pt;">);<o:p></o:p></span></div><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><span style="font-family: Consolas; font-size: 10.5pt;"> myConnection.</span><span style="color: #2b91af; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Open</span><span style="font-family: Consolas; font-size: 10.5pt;">();<o:p></o:p></span></div><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><span style="font-family: Consolas; font-size: 10.5pt;"> myCommand = </span><span style="color: darkblue; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">new</span><span style="font-family: Consolas; font-size: 10.5pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">OleDbCommand</span><span style="font-family: Consolas; font-size: 10.5pt;">(strSQL, myConnection);<o:p></o:p></span></div><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><br /></div><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><span style="font-family: Consolas; font-size: 10.5pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">OleDbDataAdapter</span><span style="font-family: Consolas; font-size: 10.5pt;"> adp=</span><span style="color: darkblue; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">new</span><span style="font-family: Consolas; font-size: 10.5pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">OledbDataAdapter</span><span style="font-family: Consolas; font-size: 10.5pt;">(myCommand);<o:p></o:p></span></div><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><span style="font-family: Consolas; font-size: 10.5pt;"> dataset ds=</span><span style="color: darkblue; font-family: Consolas; font-size: 10.5pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">new</span><span style="font-family: Consolas; font-size: 10.5pt;"> dataset();<o:p></o:p></span></div><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><span style="font-family: Consolas; font-size: 10.5pt;"> adp.fill(ds);<o:p></o:p></span></div><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><span style="font-family: Consolas; font-size: 10.5pt;"> gridview.datasource=ds;<o:p></o:p></span></div><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><span style="font-family: Consolas; font-size: 10.5pt;"> gridview.databind();</span><span style="font-family: Consolas; font-size: 10.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><span style="font-family: Consolas; font-size: 10.5pt;"><br /></span></div><div class="MsoNormal" style="background: #EEEEEE; line-height: 13.5pt; margin-bottom: .0001pt; margin-bottom: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt; vertical-align: baseline;"><span style="font-family: Consolas; font-size: 10.5pt;"><br /></span></div><br /><div class="MsoNormal"><br /></div><div class="MsoNormal"><o:p><br /></o:p></div><div class="MsoNormal"><o:p>I Think above code is help you to understand the data binding of access to the grid.</o:p></div></div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-60688763732981608052013-12-29T00:01:00.000-08:002014-01-10T22:03:55.297-08:00Using Model type to get the Values from the FORM POST - ASP.MVC<div dir="ltr" style="text-align: left;" trbidi="on">In this article we are going to see how to get the values from the FROM POST using Model type.<br /><br /><b><span style="color: red;">HTML</span></b><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> (Html.BeginForm())<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationSummary(<span style="color: blue;">true</span>)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">fieldset</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">width</span><span style="color: blue;">:300px"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">legend</span><span style="color: blue;">></span>Employee<span style="color: blue;"></</span><span style="color: maroon;">legend</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.LabelFor(m => m.EmployeeName)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.EditorFor(m => m.EmployeeName)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationMessageFor(m=>m.EmployeeName)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.LabelFor(x => x.Country)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.EditorFor(x => x.Country)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationMessageFor(x=>x.Country)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.LabelFor(x => x.DepartmentId, <span style="color: #a31515;">"Department"</span>)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DropDownList(<span style="color: #a31515;">"DepartmentId"</span>, <span style="color: blue;">new</span> <span style="color: #2b91af;">List</span><<span style="color: #2b91af;">SelectListItem</span>>(){<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectListItem</span>(){Text=<span style="color: #a31515;">"TECH"</span>,Value=<span style="color: #a31515;">"1"</span>},<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectListItem</span>(){Text=<span style="color: #a31515;">"HR"</span>,Value=<span style="color: #a31515;">"2"</span>},<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectListItem</span>(){Text=<span style="color: #a31515;">"Finance"</span>,Value=<span style="color: #a31515;">"3"</span>}<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }, <span style="color: #a31515;">"Select Department"</span>)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationMessageFor(x=>x.DepartmentId)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.LabelFor(x=>x.Married)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DropDownList(<span style="color: #a31515;">"Married"</span>,<span style="color: blue;">new</span><span style="color: #2b91af;">List</span><<span style="color: #2b91af;">SelectListItem</span>>(){<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectListItem</span>(){Text=<span style="color: #a31515;">"Yes"</span>,Value=<span style="color: #a31515;">"YES"</span>},<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectListItem</span>(){Text=<span style="color: #a31515;">"No"</span>,Value=<span style="color: #a31515;">"NO"</span>} <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> })<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationMessageFor(x=>x.Married)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">input</span> <span style="color: red;">type</span><span style="color: blue;">="submit"</span><span style="color: red;">value</span><span style="color: blue;">="Create"</span><span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">fieldset</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">br</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@</span><span style="font-family: Consolas; font-size: 9.5pt;">Html.ActionLink(<span style="color: #a31515;">"Back to List"</span>,<span style="color: #a31515;">"Index"</span>,<span style="color: #a31515;">"Department"</span>)<o:p></o:p></span></div><br /><div class="MsoNormal"><br /></div><b><span style="color: red;"><br /></span></b><b><span style="color: red;">C#</span></b><br /><b><span style="color: red;"><br /></span></b><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt; text-indent: 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;">[<span style="color: #2b91af;">HttpGet</span>]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">ActionName</span>(<span style="color: #a31515;">"Create"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span>Create_Launch()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> View();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> </span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">HttpPost</span>]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span>Create(<span style="color: #2b91af;">Employee</span> emp)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">BusLayer</span> bl = <span style="color: blue;">new</span> <span style="color: #2b91af;">BusLayer</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> bl.Create(emp.EmployeeName, emp.Country, emp.Married, emp.DepartmentId);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> RedirectToAction(<span style="color: #a31515;">"Details"</span>, <span style="color: blue;">new</span> { id = emp.DepartmentId });<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"> Below code have employee model object but the value if update by the UpdateModel method.</div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">HttpPost</span>]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">ActionName</span>(<span style="color: #a31515;">"Create"</span>)]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span>Create_Submit()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">BusLayer</span><span style="font-family: Consolas; font-size: 9.5pt;"> bl = <span style="color: blue;">new</span><span style="color: #2b91af;">BusLayer</span>();</span><br /> <div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Employee</span> emp = <span style="color: blue;">new</span><span style="color: #2b91af;">Employee</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> TryUpdateModel(emp);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (ModelState.IsValid)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> { <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> bl.Create(emp.EmployeeName, emp.Country, emp.Married, emp.DepartmentId);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> RedirectToAction(<span style="color: #a31515;">"Details"</span>, <span style="color: blue;">new</span>{ id = emp.DepartmentId });<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> RedirectToAction(<span style="color: #a31515;">"Create"</span>);</span> </div></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><br /><div class="MsoNormal"><br /></div><div class="MsoNormal"><o:p><br /></o:p></div><div class="MsoNormal"><o:p>From this article you can learn the various ways to get the value of form values from the model type.</o:p></div></div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-90882597071089277222013-12-28T21:36:00.000-08:002014-01-10T22:03:55.396-08:00Images slideshow change the image every 1 second async in ASP.NET<div dir="ltr" style="text-align: left;" trbidi="on">In this article we are going to see how to change the image dynamically at every one second async like image slideshow. For this we are using the script manager. To update the image async place the img control inside the update panel.<br /><br />Place the files inside a Folder.Drag and drop the timer control inside the update panel and set the time interval 1000 milliseconds.<br /><br /><b><span style="color: red;">HTML</span></b><br /><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">form</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">id</span><span style="color: blue;">="form1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">ScriptManager</span> <span style="color: red;">ID</span><span style="color: blue;">="ScriptManager1"</span><span style="color: red;">runat</span><span style="color: blue;">="server"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">ScriptManager</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">UpdatePanel</span> <span style="color: red;">ID</span><span style="color: blue;">="UpdatePanel1"</span><span style="color: red;">runat</span><span style="color: blue;">="server"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">ContentTemplate</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">width</span><span style="color: blue;">:200px;</span><span style="color: red;">height</span><span style="color: blue;">:50px"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Image</span> <span style="color: red;">Width</span><span style="color: blue;">="400px"</span><span style="color: red;">Height</span><span style="color: blue;">="300px"</span><span style="color: red;">ID</span><span style="color: blue;">="Image1"</span><span style="color: red;">runat</span><span style="color: blue;">="server"</span><span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Timer</span> <span style="color: red;">ID</span><span style="color: blue;">="Timer1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span><span style="color: red;">Interval</span><span style="color: blue;">="1000"</span><span style="color: red;">ontick</span><span style="color: blue;">="Timer1_Tick"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Timer</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">ContentTemplate</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">UpdatePanel</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">form</span><span style="color: blue;">><o:p></o:p></span></span></div><br /><div class="MsoNormal"><br /></div><b><span style="color: red;"><br /></span></b><b><span style="color: red;">C#</span></b><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">protected</span> <span style="color: blue;">void</span>Page_Load(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">protected</span> <span style="color: blue;">void</span>Timer1_Tick(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Random</span> rand = <span style="color: blue;">new</span> <span style="color: #2b91af;">Random</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> Image1.ImageUrl = <span style="color: #a31515;">"~/images/"</span>+ rand.Next(1, 8) + <span style="color: #a31515;">".jpg"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><br /><b><span style="color: red;">Output:</span></b><br /><div class="MsoNormal"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJMnAb5RDPCdoKAMVZxyzB-ROVlKJiD2hAh8GIVgvYdIGN-3_AqP_-ld4TFHSpvHPlRT7lg-efYFiomI79Ou2dwdYpkxYObBkYE_mXraxTuygO32T8cusFpEXuZqypieD0T08HmQ6AmRMM/s1600/3.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="287" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJMnAb5RDPCdoKAMVZxyzB-ROVlKJiD2hAh8GIVgvYdIGN-3_AqP_-ld4TFHSpvHPlRT7lg-efYFiomI79Ou2dwdYpkxYObBkYE_mXraxTuygO32T8cusFpEXuZqypieD0T08HmQ6AmRMM/s320/3.jpg" width="320" /></a></div><br /></div><br />From this article you can learn how to change the image dynamically and show as image slideshow.</div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-34220460972486673152013-12-28T07:52:00.000-08:002014-01-10T22:03:55.254-08:00Various ways to get the values from the form post to the controller action - ASP.MVC<div dir="ltr" style="text-align: left;" trbidi="on">In this article we are going to see the various ways of accessing a values from the view form post in the<br />action.<br /><br /><b><span style="color: red;">HTML</span></b> :<br /><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@model </span><span style="font-family: Consolas; font-size: 9.5pt;">TestingMvc.Models.<span style="color: #2b91af;">Employee</span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@{</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> ViewBag.Title = <span style="color: #a31515;">"Create Employee"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">}</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">h2</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> Create Employee<span style="color: blue;"></</span><span style="color: maroon;">h2</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> (Html.BeginForm())<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationSummary(<span style="color: blue;">true</span>)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">fieldset</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">width</span><span style="color: blue;">:300px"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">legend</span><span style="color: blue;">></span>Employee<span style="color: blue;"></</span><span style="color: maroon;">legend</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.LabelFor(m => m.EmployeeName)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.EditorFor(m => m.EmployeeName)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationMessageFor(m=>m.EmployeeName)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.LabelFor(x => x.Country)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.EditorFor(x => x.Country)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationMessageFor(x=>x.Country)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.LabelFor(x => x.DepartmentId, <span style="color: #a31515;">"Department"</span>)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DropDownList(<span style="color: #a31515;">"Departments"</span>, <span style="color: blue;">new</span> <span style="color: #2b91af;">List</span><<span style="color: #2b91af;">SelectListItem</span>>(){<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectListItem</span>(){Text=<span style="color: #a31515;">"TECH"</span>,Value=<span style="color: #a31515;">"1"</span>},<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectListItem</span>(){Text=<span style="color: #a31515;">"HR"</span>,Value=<span style="color: #a31515;">"2"</span>},<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectListItem</span>(){Text=<span style="color: #a31515;">"Finance"</span>,Value=<span style="color: #a31515;">"3"</span>}<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> }, <span style="color: #a31515;">"Select Department"</span>)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationMessageFor(x=>x.DepartmentId)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.LabelFor(x=>x.Married)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DropDownList(<span style="color: #a31515;">"Married"</span>,<span style="color: blue;">new</span> <span style="color: #2b91af;">List</span><<span style="color: #2b91af;">SelectListItem</span>>(){<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectListItem</span>(){Text=<span style="color: #a31515;">"Yes"</span>,Value=<span style="color: #a31515;">"YES"</span>},<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectListItem</span>(){Text=<span style="color: #a31515;">"No"</span>,Value=<span style="color: #a31515;">"NO"</span>} <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> })<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationMessageFor(x=>x.Married)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">input</span> <span style="color: red;">type</span><span style="color: blue;">="submit"</span> <span style="color: red;">value</span><span style="color: blue;">="Create"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">fieldset</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">br</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">/></span><o:p></o:p></span></div><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-highlight: yellow;">@</span><span style="font-family: Consolas; font-size: 9.5pt; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">Html.ActionLink(<span style="color: #a31515;">"Back to List"</span>,<span style="color: #a31515;">"Index"</span>,<span style="color: #a31515;">"Department"</span>)</span><br /><br /><b><span style="color: red;">FormCollection</span></b>:<br /><span style="font-family: Consolas; font-size: 9.5pt;"> </span>From this FormCollection developer can get the all controls values present with in the form while post.Values are stored as key/values pairs<br /><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">HttpPost</span>]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span>Create(<span style="color: #2b91af;">FormCollection</span> form)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> { <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">BusLayer</span> bl = <span style="color: blue;">new</span> <span style="color: #2b91af;">BusLayer</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> bl.Create(form[<span style="color: #a31515;">"EmployeeName"</span>], form[<span style="color: #a31515;">"Country"</span>], form[<span style="color: #a31515;">"Married"</span>], <span style="color: blue;">int</span>.Parse(form[<span style="color: #a31515;">"Departments"</span>]));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> RedirectToAction(<span style="color: #a31515;">"Details"</span>, <span style="color: blue;">new</span> { id=<span style="color: blue;">int</span>.Parse(form[<span style="color: #a31515;">"Departments"</span>])}); <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> </span> </div><b><span style="color: red;">Parameter</span></b>:<br /> From This method all the elements are mention as parameter with the same name as the control name to the input for action then it is default mapped the values to that variable, parameters can be in any order.<br /><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">HttpPost</span>]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span>Create(<span style="color: blue;">string</span> employeename,<span style="color: blue;">string</span> country,<span style="color: blue;">string</span>married,<span style="color: blue;">int</span> departments)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> { <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">BusLayer</span> bl = <span style="color: blue;">new</span> <span style="color: #2b91af;">BusLayer</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> bl.Create(employeename,country,married,departments);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> RedirectToAction(<span style="color: #a31515;">"Details"</span>, <span style="color: blue;">new</span> { id=departments}); <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><br /></div><br /><div class="MsoNormal"><o:p><b><span style="color: red;">Output:</span></b></o:p></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirrB__kiDriZDzBb3T058w2bfuUCyLa_F9KZ5L_vT8v0Tp94XDvr-xWkLPF6Bh2SIEvqVD8IOOQIAm9HTwCz529Vm2dcxyxlbaZ16gQVzoyh3qQwO7r9p1d_SH95SKA2JjQ66m-L4CruS3/s1600/Emp4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirrB__kiDriZDzBb3T058w2bfuUCyLa_F9KZ5L_vT8v0Tp94XDvr-xWkLPF6Bh2SIEvqVD8IOOQIAm9HTwCz529Vm2dcxyxlbaZ16gQVzoyh3qQwO7r9p1d_SH95SKA2JjQ66m-L4CruS3/s1600/Emp4.png" /></a></div><div class="MsoNormal"><o:p><br /></o:p></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><o:p><br /></o:p></div>From this article you can learn the various ways of access a values from the request posted from the client.</div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0tag:blogger.com,1999:blog-5150847477515676948.post-51955769073448918022013-12-28T07:38:00.000-08:002014-01-10T22:03:55.283-08:00Submit a FORM in ASP.NET MVC <div dir="ltr" style="text-align: left;" trbidi="on">In this article we are going to see how to submit a form to the controller,so let we take a example add a new employee to the list and submit it.<br /><br />Create a Employee Controller and action in a name of Create which is mention as HttpGet that means it is a Get Request so it is called at the load time, Now for this action create a View.<br /><b><span style="color: red;"><br /></span></b><b><span style="color: red;">C#</span></b><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">HttpGet</span>]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span>Create()<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> View();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><br /><div class="MsoNormal"><br /></div><br /><b><span style="color: red;">HTML</span></b><br /><br /><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@model </span><span style="font-family: Consolas; font-size: 9.5pt;">TestingMvc.Models.<span style="color: #2b91af;">Employee</span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@{</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> ViewBag.Title = <span style="color: #a31515;">"Create Employee"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">}</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">h2</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> Create Employee<span style="color: blue;"></</span><span style="color: maroon;">h2</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; mso-highlight: yellow;">@</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> (Html.BeginForm())<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationSummary(<span style="color: blue;">true</span>)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">fieldset</span> <span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">width</span><span style="color: blue;">:300px"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">legend</span><span style="color: blue;">></span>Employee<span style="color: blue;"></</span><span style="color: maroon;">legend</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.LabelFor(m => m.EmployeeName)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.EditorFor(m => m.EmployeeName)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationMessageFor(m=>m.EmployeeName)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.LabelFor(x => x.Country)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.EditorFor(x => x.Country)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationMessageFor(x=>x.Country)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.LabelFor(x => x.DepartmentId, <span style="color: #a31515;">"Department"</span>)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DropDownList(<span style="color: #a31515;">"Departments"</span>, <span style="color: blue;">new</span> <span style="color: #2b91af;">List</span><<span style="color: #2b91af;">SelectListItem</span>>(){<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectListItem</span>(){Text=<span style="color: #a31515;">"TECH"</span>,Value=<span style="color: #a31515;">"1"</span>},<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectListItem</span>(){Text=<span style="color: #a31515;">"HR"</span>,Value=<span style="color: #a31515;">"2"</span>},<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectListItem</span>(){Text=<span style="color: #a31515;">"Finance"</span>,Value=<span style="color: #a31515;">"3"</span>}<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> }, <span style="color: #a31515;">"Select Department"</span>)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationMessageFor(x=>x.DepartmentId)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-label"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.LabelFor(x=>x.Married)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span> <span style="color: red;">class</span><span style="color: blue;">="editor-field"></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.DropDownList(<span style="color: #a31515;">"Married"</span>,<span style="color: blue;">new</span> <span style="color: #2b91af;">List</span><<span style="color: #2b91af;">SelectListItem</span>>(){<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectListItem</span>(){Text=<span style="color: #a31515;">"Yes"</span>,Value=<span style="color: #a31515;">"YES"</span>},<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">SelectListItem</span>(){Text=<span style="color: #a31515;">"No"</span>,Value=<span style="color: #a31515;">"NO"</span>} <o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> })<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;">@</span>Html.ValidationMessageFor(x=>x.Married)<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">input</span> <span style="color: red;">type</span><span style="color: blue;">="submit"</span> <span style="color: red;">value</span><span style="color: blue;">="Create"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">fieldset</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">br</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">/></span><o:p></o:p></span></div><span style="background: yellow; font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin; mso-highlight: yellow;">@</span><span style="font-family: Consolas; font-size: 9.5pt; line-height: 115%; mso-ansi-language: EN-US; mso-bidi-language: AR-SA; mso-fareast-font-family: Calibri; mso-fareast-language: EN-US; mso-fareast-theme-font: minor-latin;">Html.ActionLink(<span style="color: #a31515;">"Back to List"</span>,<span style="color: #a31515;">"Index"</span>,<span style="color: #a31515;">"Department"</span>)</span><br /><br />For Post the form we have to create a another action with same name with HttpPost as Attribute.<br /><br /><b><span style="color: red;">C#<span style="font-family: Consolas; font-size: 9.5pt;"> </span></span></b><br /><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> [<span style="color: #2b91af;">HttpPost</span>]<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: #2b91af;">ActionResult</span>Create(<span style="color: #2b91af;">FormCollection</span> form)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> { <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">BusinessLayer</span> bl = <span style="color: blue;">new</span> <span style="color: #2b91af;">BusinessLayer</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> bl.Create(form[<span style="color: #a31515;">"EmployeeName"</span>], form[<span style="color: #a31515;">"Country"</span>], form[<span style="color: #a31515;">"Married"</span>], <span style="color: blue;">int</span>.Parse(form[<span style="color: #a31515;">"Departments"</span>]));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> RedirectToAction(<span style="color: #a31515;">"Details"</span>, <span style="color: blue;">new</span> { id=<span style="color: blue;">int</span>.Parse(form[<span style="color: #a31515;">"Departments"</span>])}); <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin: 0in 0in 0.0001pt 0.5in;"><br /></div><br /><div class="MsoNormal"><o:p><b><span style="color: red;"> Businnes Logic:</span></b></o:p></div><div class="MsoNormal"><o:p><br /></o:p></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">BusLayer</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">void</span> Create(<span style="color: blue;">string</span> name, <span style="color: blue;">string</span>country, <span style="color: blue;">string</span> married, <span style="color: blue;">int</span> departmentid)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">SqlConnection</span> con = <span style="color: blue;">new</span><span style="color: #2b91af;">SqlConnection</span>(<span style="color: #2b91af;">ConfigurationManager</span>.ConnectionStrings[<span style="color: #a31515;">"EmployeeDbContext"</span>].ConnectionString);<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> con.Open();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">try</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">SqlCommand</span>cmd = <span style="color: blue;">new</span> <span style="color: #2b91af;">SqlCommand</span>();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.Connection = con;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.CommandType = System.Data.<span style="color: #2b91af;">CommandType</span>.StoredProcedure;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.CommandText = <span style="color: #a31515;">"EMP_ADD"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.Parameters.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">SqlParameter</span>(<span style="color: #a31515;">"@NAME"</span>, name));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.Parameters.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">SqlParameter</span>(<span style="color: #a31515;">"@DEPT"</span>, departmentid));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.Parameters.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">SqlParameter</span>(<span style="color: #a31515;">"@COUNTRY"</span>, country));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.Parameters.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">SqlParameter</span>(<span style="color: #a31515;">"@MARRIED"</span>, married));<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> cmd.ExecuteNonQuery();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">finally</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> con.Close();<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal"><o:p> </o:p></div><div class="MsoNormal"><b><span style="color: red;">OUTPUT</span></b>:<br /><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix-GMZXtM_MoLUJmL9cUSsqkcDKkwnXBzBv-1_iR3IPFf_HR3W914qZzG8RnQPC7-VohY9AQ_3j3-yfq7cLO1rTabJmRxYT7YQM5bbcP0MNlkFAYkKFEB_DRf0bYFqIKKhqofItlU3dC2O/s1600/Emp4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEix-GMZXtM_MoLUJmL9cUSsqkcDKkwnXBzBv-1_iR3IPFf_HR3W914qZzG8RnQPC7-VohY9AQ_3j3-yfq7cLO1rTabJmRxYT7YQM5bbcP0MNlkFAYkKFEB_DRf0bYFqIKKhqofItlU3dC2O/s1600/Emp4.png" /></a></div><br /><br /></div><div class="MsoNormal"><o:p><b><span style="color: red;">SQL SCRIPT</span></b> :</o:p></div><div class="MsoNormal"><o:p><br /></o:p></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">CREATE</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: blue;">PROCEDURE</span> EMP_ADD<span style="color: grey;">(<o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">@NAME <span style="color: blue;">VARCHAR</span><span style="color: grey;">(</span>100<span style="color: grey;">),<o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">@DEPT <span style="color: blue;">VARCHAR</span><span style="color: grey;">(</span>100<span style="color: grey;">),<o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">@COUNTRY <span style="color: blue;">VARCHAR</span><span style="color: grey;">(</span>20<span style="color: grey;">),<o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">@MARRIED <span style="color: blue;">VARCHAR</span><span style="color: grey;">(</span>4<span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: grey; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">)<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">AS<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">BEGIN<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">SET</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: blue;">NOCOUNT</span> <span style="color: blue;">ON<o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: blue;">INSERT</span> <span style="color: blue;">INTO</span><o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> EMPTABLE<span style="color: grey;">(<o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> NAME<span style="color: grey;">,<o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> DEPTID<span style="color: grey;">,<o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> COUNTRY<span style="color: grey;">,<o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> MARRIED<o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: blue;">VALUES</span><span style="color: grey;">(<o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: magenta;">UPPER</span><span style="color: grey;">(</span>@NAME<span style="color: grey;">),<o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> @DEPT<span style="color: grey;">,<o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: magenta;">UPPER</span><span style="color: grey;">(</span>@COUNTRY<span style="color: grey;">),<o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: magenta;">UPPER</span><span style="color: grey;">(</span>@MARRIED<span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><br /></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">SET</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: blue;">NOCOUNT</span> <span style="color: blue;">OFF</span> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <o:p></o:p></span></div><div class="MsoNormal" style="margin-bottom: 0.0001pt;"><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">END<o:p></o:p></span></div><div class="MsoNormal"><o:p> </o:p></div><div class="MsoNormal"><br /></div><div class="MsoNormal"><o:p><br /></o:p></div><br />When the Form is submitted the values and controls are submitted as form collection to the action, so each and every control is stored as Key value pairs.<br /><br /></div>DotnetVisiohttp://www.blogger.com/profile/09365297517618959915noreply@blogger.com0