<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Paul Sheriff's Blog for the Real World</title><link>https://weblogs.asp.net:443/psheriff/paul-sheriff-s-blog-for-the-real-world</link><description>This blog is to share my tips and tricks garnered over 25+ years in the IT industry</description><item><title>Manipulating HTML Tables – Part 5 (Editing Rows using an ID)</title><link>https://weblogs.asp.net:443/psheriff/manipulating-html-tables-%E2%80%93-part-5-editing-rows-using-an-id</link><description>&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;While we have been concentrating on just working with client-side code, at some point you are going to have to send the data back to the server. In addition, you will most likely get data from a server as well. Most of us assign a primary key (unique number) to each row of data. This &amp;lsquo;ID&amp;rsquo; can be used to identify each row of data within the table. In this blog post you will see how you might use a primary key when manipulating data within a table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;b&gt;NOTE&lt;/b&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;: You should probably go back and read the previous blog posts in order to see what we are doing with tables.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;The HTML&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;The HTML is exactly like that shown in my last blog post. I am presenting it here just so you can see it in its entirety.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;div class="container"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;h1 class="text-center"&amp;gt;Add Row to Table&amp;lt;/h1&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="row"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="center-block col-sm-6"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;table id="peopleTable" class="table table-bordered&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;table-condensed table-striped"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;thead&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;th&amp;gt;Edit&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;th&amp;gt;First Name&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;th&amp;gt;Last Name&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;th&amp;gt;Email&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;th&amp;gt;Delete&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/thead&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/table&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="row"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="center-block col-sm-6"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="panel panel-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="panel-heading"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Person Information&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="panel-body"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label for="firstname"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; First Name&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="text"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="form-control"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="Paul"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="firstname" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label for="lastname"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Last Name&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="text"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="form-control"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="Sheriff"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="lastname" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label for="email"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Email&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="email"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="form-control"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="PSheriff@pdsa.com"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="email" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="panel-footer"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="row"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="col-xs-12"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;button type="button" id="updateButton"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class="btn btn-primary"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; onclick="updatePerson();"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Add&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/button&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;o:p&gt;&amp;nbsp; &lt;img width="569" height="591" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/HTMLTables4.png" /&gt; &lt;/o:p&gt;&lt;/p&gt;
&lt;p class="ScrShotWide"&gt;&lt;/p&gt;
&lt;p class="figcaption"&gt;Figure 1: Use a unique ID for editing and deleting records in a table&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;h2&gt;Add Two Variables&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;When adding a new record, you assign a new unique ID to that record. This means you need a variable within your &amp;lt;script&amp;gt; tag that is not a part of any function. This makes that variable global to this page. Let&amp;rsquo;s call this variable &amp;lsquo;nextId&amp;rsquo;. You also want to keep track of the record you are currently editing if the user clicks on the edit button. Let&amp;rsquo;s call this variable &amp;lsquo;currentId&amp;rsquo;. The code to do this is shown below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Next id for adding a new person&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; var nextId = 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // ID of person currently editing&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; var currentId = 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Building a Row for the Table&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;You will either use the nextId variable or the currentId variable when you build a row to be added to your HTML table. So you build your buildPersonTableRow() function to accept a parameter called &amp;lsquo;id&amp;rsquo; to which you can pass either of those two variables. This unique number will be added into a data- attribute on each button. The code to do this is shown below:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;function buildPersonTableRow(&lt;b&gt;id&lt;/b&gt;) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; var ret =&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; "&amp;lt;tr&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;button type='button' " +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "onclick='displayPerson(this);' " +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "class='btn btn-default' " +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;"data-id='" + id + "'&amp;gt;"&lt;/b&gt; +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;span class='glyphicon glyphicon-edit' /&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;/button&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;" + $("#firstname").val() + "&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;" + $("#lastname").val() + "&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;" + $("#email").val() + "&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;button type='button' " +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "onclick='deletePerson(this);' " +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "class='btn btn-default' " +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;"data-id='" + id + "'&amp;gt;"&lt;/b&gt; +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;span class='glyphicon glyphicon-remove' /&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;/button&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; "&amp;lt;/tr&amp;gt;"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; return ret;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Getting the Current ID&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;When the user clicks on the Edit button in the table, you call the displayPerson() function passing in the Edit button. In this function is where you need to grab the data- attribute that contains the unique id and assign it to the &amp;lsquo;currentId&amp;rsquo; variable. The displayPerson() function is shown below:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;function displayPerson(ctl) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; var row = $(ctl).parents("tr");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; var cols = row.children("td");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;b&gt;currentId = $($(cols[0]).children("button")[0]).data("id");&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $("#firstname").val($(cols[1]).text());&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $("#lastname").val($(cols[2]).text());&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $("#email").val($(cols[3]).text());&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Change Update Button Text&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $("#updateButton").text("Update");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;This function retrieves the current row the user clicked on using the parents() function on the &amp;lsquo;Edit&amp;rsquo; button passed in and locating the &amp;lt;tr&amp;gt; tag. Once you have the row of the table you can use the children() function to retrieve an array of all of the &amp;lt;td&amp;gt; elements for that row. Since the Edit button is in the first column of the row, you can retrieve that button using the line shown in bold above. You then get the current id using the data() function to retrieve the data-id attribute&amp;rsquo;s value.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;h2&gt;Update a Person&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;You now need to modify the updatePersonInTable() function to find the row in the table that contains this unique ID. You call this function using &lt;i&gt;updatePersonInTable(currentId);&lt;/i&gt;. This function uses that id to locate the button that contains the data- attribute within your table. An example of the jQuery selector that might be built would be $(&amp;ldquo;#peopleTable button[data-id=&amp;rsquo;2&amp;rsquo;]). This selector returns a row in the table that has the data for the person you wish to edit. One you locate the row, replace that row in the table with the contents from what the user entered in the input fields on this form. The code for the updatePersonInTable() function is shown below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;function updatePersonInTable(id) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Find person in &amp;lt;table&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; var row = $("#peopleTable button[data-id='" + id + "']")&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .parents("tr")[0];&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Add changed row to table&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $(row).after(buildPersonTableRow(id));&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Remove original row&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $(row).remove();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Change Update Button Text&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $("#updateButton").text("Add");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Adding a New Row&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;Each time you add a new row to the table, use the &amp;lsquo;nextId&amp;rsquo; variable to build the row of data. So you rewrite your addPersonToTable() function as shown below. Notice how you pass in the nextId variable to the buildPersonTableRow() function. After this new person has been created, increment the &amp;lsquo;nextId&amp;rsquo; variable so the next person you add gets the next unique id.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;function addPersonToTable() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // First check if a &amp;lt;tbody&amp;gt; tag exists, add one if not&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; if ($("#peopleTable tbody").length == 0) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#peopleTable").append("&amp;lt;tbody&amp;gt;&amp;lt;/tbody&amp;gt;");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Append row to table&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $("#peopleTable tbody").append(&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; buildPersonTableRow(&lt;b&gt;nextId&lt;/b&gt;));&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Increment next ID to use&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; nextId += 1;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;While the code in this blog post is not needed if you are just working 100% client-side, it will come in handy once you start working with data from the server. Using the data- attributes to store the primary keys is a great way to keep track of your unique ids.&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</description><pubDate>Tue, 03 Mar 2015 08:02:13 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/manipulating-html-tables-%E2%80%93-part-5-editing-rows-using-an-id</guid><category>HTML</category><category>CSS</category><category>JavaScript</category><category>jQuery</category><category>Bootstrap</category></item><item><title>Manipulating HTML Tables – Part 4 (Editing Rows)</title><link>https://weblogs.asp.net:443/psheriff/manipulating-html-tables-%E2%80%93-part-4-editing-rows</link><description>&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;You have learned how to add rows and delete rows from an HTML table in my last 3 blog posts. Now, let&amp;rsquo;s turn our attention to editing rows in an HTML table. Just like you added a Delete button to each row in your table, you will now add an Edit button as well (Figure 1).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt; &lt;img width="548" height="620" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/HTMLTables3.png" /&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt; &lt;v:stroke joinstyle="miter"&gt; &lt;v:formulas&gt; &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt; &lt;v:f eqn="sum @0 1 0"&gt; &lt;v:f eqn="sum 0 0 @1"&gt; &lt;v:f eqn="prod @2 1 2"&gt; &lt;v:f eqn="prod @3 21600 pixelWidth"&gt; &lt;v:f eqn="prod @3 21600 pixelHeight"&gt; &lt;v:f eqn="sum @0 0 1"&gt; &lt;v:f eqn="prod @6 1 2"&gt; &lt;v:f eqn="prod @7 21600 pixelWidth"&gt; &lt;v:f eqn="sum @8 21600 0"&gt; &lt;v:f eqn="prod @7 21600 pixelHeight"&gt; &lt;v:f eqn="sum @10 21600 0"&gt; &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt; &lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt; &lt;o:lock v:ext="edit" aspectratio="t"&gt; &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;v:shape id="Picture_x0020_1" o:spid="_x0000_i1025" type="#_x0000_t75" style="width: 411pt; height: 465pt; visibility: visible; mso-wrap-style: square;"&gt; &lt;v:imagedata src="file:///D:\Temp\msohtmlclip1\01\clip_image001.png" o:title=""&gt; &lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;Figure 1: Add an edit button to allow a user to edit a single row in the table&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;h2&gt;The HTML&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;The HTML is similar to that shown in my last blog post, with another &amp;lt;th&amp;gt; added to allow for a column where you will place an &amp;lsquo;Edit&amp;rsquo; button. I have highlighted the change in bold in the code below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;div class="container"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;h1 class="text-center"&amp;gt;Edit Row in a Table&amp;lt;/h1&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="row"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="center-block col-sm-6"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;table id="peopleTable" class="table table-bordered&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;table-condensed table-striped"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;thead&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&amp;lt;th&amp;gt;Edit&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;th&amp;gt;First Name&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;th&amp;gt;Last Name&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;th&amp;gt;Email&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;th&amp;gt;Delete&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/thead&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/table&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="row"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="center-block col-sm-6"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="panel panel-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="panel-heading"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Person Information&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="panel-body"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label for="firstname"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; First Name&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="text"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="form-control"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="Paul"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="firstname" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label for="lastname"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Last Name&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="text"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="form-control"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="Sheriff"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="lastname" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label for="email"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Email&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="email"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="form-control"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="PSheriff@pdsa.com"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="email" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="panel-footer"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="row"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="col-xs-12"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;button type="button" id="updateButton"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class="btn btn-primary"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; onclick="updatePerson();"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Add&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/button&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Creating a Row with an Edit Button&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;Just like you added a button for deleting a row when you add the user input to the row in the table, you add a button for editing a row as well. This is done exactly the same as what you did for the delete button, but the onclick event calls a different function, of course. In the code highlighted in bold you see the edit button is created. In the onclick for this button you call a function named displayPerson().&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;function buildPersonTableRow() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; var ret =&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; "&amp;lt;tr&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;button type='button' " +&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "onclick='displayPerson(this);' " +&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "class='btn btn-default'&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;span class='glyphicon glyphicon-edit' /&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;/button&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;" + $("#firstname").val() + "&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;" + $("#lastname").val() + "&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;" + $("#email").val() + "&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;button type='button' " +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "onclick='deletePerson(this);' " +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "class='btn btn-default'&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;span class='glyphicon glyphicon-remove' /&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;/button&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; "&amp;lt;/tr&amp;gt;"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; return ret;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;Since you need to build the exact same HTML regardless of whether you are adding a new row, or replacing an existing row with new data, this new function called buildPersonTableRow() is created.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;h2&gt;Display Data in Input Fields&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;When the user clicks on the Edit button in the table you need to do a couple of things. First you need to get the current row that is being edited right now and store that for future use. To do this you need to create a variable that is outside of any function within your &amp;lt;script&amp;gt; tags.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Current row being edited&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; var currentRow = null;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;Next you write the displayPerson() function to calculate the current row by getting the &amp;lt;tr&amp;gt; tag that is the parent for the &amp;lsquo;Edit&amp;rsquo; button. You now get the individual &amp;lt;td&amp;gt; columns in an array by selecting all &amp;lt;td&amp;gt; elements from the current row. You use the appropriate columns to retrieve each input field such as first name, last name and email. You use the val() function to update each text box from each column of data. Finally, so we know that we are in &amp;lsquo;Edit&amp;rsquo; mode as opposed to &amp;lsquo;Add&amp;rsquo; mode, you change the text of the &amp;lsquo;updateButton&amp;rsquo; to &amp;lsquo;Update&amp;rsquo;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;function displayPerson(ctl) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; currentRow = $(ctl).parents("tr");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; var cols = currentRow.children("td");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $("#firstname").val($(cols[1]).text());&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $("#lastname").val($(cols[2]).text());&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $("#email").val($(cols[3]).text());&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Change Update Button Text&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $("#updateButton").text("Update");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Updating the Data&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;When the user clicks on the updateButton it always calls the updatePerson() function. However, depending on what the text is in the updateButton will determine whether or not we are adding or editing. Remember that when you click on the &amp;lsquo;Edit&amp;rsquo; button it changes the text of the update button. So in this function you simply test to see what that text says and perform the appropriate function based on that text.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;function updatePerson() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; if ($("#updateButton").text() == "Update") {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; updatePersonInTable();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; else {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; addPersonToTable();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;If the Update buttons&amp;rsquo; text says &amp;lsquo;Update&amp;rsquo;, call a method to update a person in the table. There are a couple of ways you can update a person. You already saved the row in the &amp;lsquo;currentRow&amp;rsquo; variable, so you could reference each cell individually in that row and update each cell in the table using the val() function of each input field. Another method is to add the changed data to the row immediately after the current row, then delete the current row from the table. I have chosen to use the latter as this allows me to reuse the buildPersonTableRow() function we wrote earlier. Lastly, change the text back to Add on the update button. You could also clear the input fields if you want so the user knows they are back in &amp;ldquo;Add&amp;rdquo; mode.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;function updatePersonInTable() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Add changed row to table&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $(currentRow).after(buildPersonTableRow());&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Remove original row&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $(currentRow).remove();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Change Update Button Text&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $("#updateButton").text("Add");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;In the last 4 blog posts you saw how to add, edit and delete rows using 100% client-side code. With just a little HTML, jQuery and JavaScript you are able to create a nice way for users to add, edit and delete records without making a bunch of round-trips to the web server. This will go a long ways towards making your web pages really fast.&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</description><pubDate>Tue, 24 Feb 2015 15:17:45 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/manipulating-html-tables-%E2%80%93-part-4-editing-rows</guid><category>HTML</category><category>CSS</category><category>JavaScript</category><category>jQuery</category><category>Bootstrap</category></item><item><title>Manipulating HTML Tables – Part 3 (Deleting Rows)</title><link>https://weblogs.asp.net:443/psheriff/manipulating-html-tables-%E2%80%93-part-3-deleting-rows</link><description>&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;My last two blog posts showed you how to add rows to an HTML table. Now, let&amp;rsquo;s learn how to delete a row from a table. In order to accomplish this you will need to add a &amp;lsquo;Delete&amp;rsquo; button to each row of the table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;The HTML&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;The HTML for this sample is similar to my last blog post, with the addition of a new &amp;lt;th&amp;gt; to allow for a column in which you place a &amp;lsquo;Delete&amp;rsquo; button. I have highlighted the change in bold in the code below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;img width="548" height="610" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/HTMLTables2.png" /&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt; &lt;v:stroke joinstyle="miter"&gt; &lt;v:formulas&gt; &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt; &lt;v:f eqn="sum @0 1 0"&gt; &lt;v:f eqn="sum 0 0 @1"&gt; &lt;v:f eqn="prod @2 1 2"&gt; &lt;v:f eqn="prod @3 21600 pixelWidth"&gt; &lt;v:f eqn="prod @3 21600 pixelHeight"&gt; &lt;v:f eqn="sum @0 0 1"&gt; &lt;v:f eqn="prod @6 1 2"&gt; &lt;v:f eqn="prod @7 21600 pixelWidth"&gt; &lt;v:f eqn="sum @8 21600 0"&gt; &lt;v:f eqn="prod @7 21600 pixelHeight"&gt; &lt;v:f eqn="sum @10 21600 0"&gt; &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt; &lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt; &lt;o:lock v:ext="edit" aspectratio="t"&gt; &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;v:shape id="Picture_x0020_1" o:spid="_x0000_i1025" type="#_x0000_t75" style="width: 411pt; height: 457.5pt; visibility: visible; mso-wrap-style: square;"&gt; &lt;v:imagedata src="file:///D:\Temp\msohtmlclip1\01\clip_image001.png" o:title=""&gt; &lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;Figure 1: Add a delete button to allow a user to delete a row from the table&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;div class="container"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;h1 class="text-center"&amp;gt;Delete Row in Table&amp;lt;/h1&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="row"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="center-block col-sm-6"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;table id="peopleTable" class="table table-bordered&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;table-condensed table-striped"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;thead&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;th&amp;gt;First Name&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;th&amp;gt;Last Name&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;th&amp;gt;Email&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&amp;lt;th&amp;gt;Delete&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/thead&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/table&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="row"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="center-block col-sm-6"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="panel panel-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="panel-heading"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Person Information&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="panel-body"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label for="firstname"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; First Name&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="text"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="form-control"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="Paul"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="firstname" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label for="lastname"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Last Name&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="text"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="form-control"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="Sheriff"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="lastname" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label for="email"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Email&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="email"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="form-control"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="PSheriff@pdsa.com"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="email" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="panel-footer"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="row"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="col-xs-12"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;button type="button" id="updateButton"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="btn btn-primary"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; onclick="updatePerson();"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Add&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/button&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;h2&gt;Adding a Row with a Delete Button&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;When you add the user input data to the row in the table, you also need to add on the additional column with a button. The button will also have its onclick event filled in with the name of a function to call to delete a row in the table. Here is the addPersonToTable() function with the additional code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;function addPersonToTable() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // First check if a &amp;lt;tbody&amp;gt; tag exists, add one if not&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; if ($("#peopleTable tbody").length == 0) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#peopleTable").append("&amp;lt;tbody&amp;gt;&amp;lt;/tbody&amp;gt;");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Append row to table&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $("#peopleTable tbody").append(&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;tr&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;" + $("#firstname").val() + "&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;" + $("#lastname").val() + "&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;" + $("#email").val() + "&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;"&amp;lt;button type='button' " +&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "onclick='deletePerson(this);' " +&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "class='btn btn-default'&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;span class='glyphicon glyphicon-remove' /&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;/button&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;/tr&amp;gt;"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;You can see in the code highlighted in bold above that you create a &amp;lt;button&amp;gt; in the last column that has the onclick event filled in with a call to a function named deletePerson(). Pass in &amp;lsquo;this&amp;rsquo; to the function so the function can figure out which row the button is in, as this is the row we need to delete.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;h2&gt;Delete a Row&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;The deletePerson() function is very simple. The instance of the &amp;lsquo;Delete&amp;rsquo; button is passed to this function. From that you can use the jQuery function parents() to locate the button&amp;rsquo;s containing &amp;lt;tr&amp;gt; tag. Once you locate that &amp;lt;tr&amp;gt; tag you use the remove() function to eliminate that row from the table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;function deletePerson(ctl) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $(ctl).parents("tr").remove();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;Deleting a row from a table is a single line of code. It is just a matter of figuring out which row you are in, then applying the remove() function to that row. When you append a new row, you create a new button for the delete functionality that can call a function to perform the delete of the current row.&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</description><pubDate>Tue, 24 Feb 2015 15:16:40 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/manipulating-html-tables-%E2%80%93-part-3-deleting-rows</guid><category>HTML</category><category>CSS</category><category>JavaScript</category><category>jQuery</category><category>Bootstrap</category></item><item><title>Manipulating HTML Tables – Part 2 (Adding Rows)</title><link>https://weblogs.asp.net:443/psheriff/manipulating-html-tables-%E2%80%93-part-2-adding-rows</link><description>&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;In my last blog post, I showed how to add a hard-coded row to a table using jQuery and JavaScript. Now, let&amp;rsquo;s make this a little more dynamic by gathering input from our user and adding that data to our table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;The HTML&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;In addition to the table shown in my last blog post, you now are adding three input fields for the user to input the data to add to the table. The user will input a first name, last name and email address (Figure 1) which will then be added to the table. Again, I am using bootstrap, but is not a requirement.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt; &lt;v:stroke joinstyle="miter"&gt; &lt;v:formulas&gt; &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt; &lt;v:f eqn="sum @0 1 0"&gt; &lt;v:f eqn="sum 0 0 @1"&gt; &lt;v:f eqn="prod @2 1 2"&gt; &lt;v:f eqn="prod @3 21600 pixelWidth"&gt; &lt;v:f eqn="prod @3 21600 pixelHeight"&gt; &lt;v:f eqn="sum @0 0 1"&gt; &lt;v:f eqn="prod @6 1 2"&gt; &lt;v:f eqn="prod @7 21600 pixelWidth"&gt; &lt;v:f eqn="sum @8 21600 0"&gt; &lt;v:f eqn="prod @7 21600 pixelHeight"&gt; &lt;v:f eqn="sum @10 21600 0"&gt; &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt; &lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt; &lt;o:lock v:ext="edit" aspectratio="t"&gt; &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;v:shape id="Picture_x0020_1" o:spid="_x0000_i1025" type="#_x0000_t75" style="width: 357pt; height: 429.75pt; visibility: visible; mso-wrap-style: square;"&gt; &lt;v:imagedata src="file:///D:\Temp\msohtmlclip1\01\clip_image001.png" o:title=""&gt; &lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;Figure 1: Add rows to a table using user input&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;div class="container"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;h1 class="text-center"&amp;gt;Add Row to Table&amp;lt;/h1&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="row"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="center-block col-sm-6"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;table id="peopleTable" class="table table-bordered&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;table-condensed table-striped"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;thead&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;th&amp;gt;First Name&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;th&amp;gt;Last Name&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;th&amp;gt;Email&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/thead&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/table&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="row"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="center-block col-sm-6"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="panel panel-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="panel-heading"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Person Information&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="panel-body"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label for="firstname"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; First Name&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="text"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;class="form-control"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="Paul"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="firstname" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label for="lastname"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Last Name&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="text"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="form-control"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="Sheriff"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="lastname" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label for="email"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Email&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type="email"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="form-control"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value="PSheriff@pdsa.com"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="email" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="panel-footer"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="row"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;div class="col-xs-12"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;button type="button" id="updateButton"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="btn btn-primary"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; onclick="updatePerson();"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Add&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/button&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;Besides the input fields, there is a &amp;lt;button&amp;gt; that when clicked upon will be responsible for adding the data entered into the table. This button, shown below, is a normal HTML button, and has an onclick event to call a function named updatePerson(). &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;button type="button" id="updateButton"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="btn btn-primary"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;onclick="updatePerson();"&lt;/b&gt;&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; Add&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/button&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Adding a Row&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;After entering data into the text boxes, the user will click on the Add button. The click will fire a function called updatePerson(). This function calls another function called addPersonToTable(). It is within this method that you find code similar to my last blog entry, but instead of hard-coded values, retrieves the values from the input fields and places them into the &amp;lt;td&amp;gt; tags.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // This function is called from the button onclick&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; function updatePerson() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Add person to Table&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; addPersonToTable();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Add row to &amp;lt;table&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; function addPersonToTable()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // First check if a &amp;lt;tbody&amp;gt; tag exists, add one if not&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($("#peopleTable tbody").length == 0) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#peopleTable").append("&amp;lt;tbody&amp;gt;&amp;lt;/tbody&amp;gt;");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Append row to the table&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#peopleTable tbody").append(&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;tr&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;" + $("#firstname").val() + "&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;" + $("#lastname").val() + "&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;" + $("#email").val() + "&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;/tr&amp;gt;"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;This code is very similar to my last blog post, but uses jQuery to retrieve the values from the text boxes. Again, notice that you still should check for a &amp;lt;tbody&amp;gt; tag and ensure it is there before adding rows to your table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;h2&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;By using jQuery and JavaScript you can build up a table without performing any post-backs to the server. This means that the results are almost instantaneous and leads to a very good user experience. Of course, you will still need a method to eventually post the data back to the server. This could be done by using JSON objects and storing the data in a hidden field. You could then supply another button to the user that would post back to the server and allow all of the added rows to be gathered from the hidden field and saved to a database.&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</description><pubDate>Tue, 24 Feb 2015 15:14:45 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/manipulating-html-tables-%E2%80%93-part-2-adding-rows</guid><category>HTML</category><category>CSS</category><category>JavaScript</category><category>jQuery</category><category>Bootstrap</category></item><item><title>Manipulating HTML Tables – Part 1 (Adding Rows)</title><link>https://weblogs.asp.net:443/psheriff/manipulating-html-tables-%E2%80%93-part-1-adding-rows</link><description>&lt;p&gt;&lt;span style="font-size: 13px;"&gt;Users continue to demand faster and more dynamic user experiences in web applications. One way to accomplish this is to start doing more with JavaScript and jQuery, thereby eliminating or reducing post-backs to the server. In this first blog post of many, I will show you how to work with HTML tables. In this first blog you will learn how to add rows to a table using JavaScript and jQuery.&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;The HTML&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;For these samples, I am using Bootstrap in order to have a nice appearance for my web page. However, Bootstrap is not required for these samples. The HTML I am using creates an empty table with just a &amp;lt;thead&amp;gt; for the headers of each column in the table. Note that there is no &amp;lt;tbody&amp;gt;. We will check for that in our jQuery and add one if necessary.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt; &lt;v:stroke joinstyle="miter"&gt; &lt;v:formulas&gt; &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt; &lt;v:f eqn="sum @0 1 0"&gt; &lt;v:f eqn="sum 0 0 @1"&gt; &lt;v:f eqn="prod @2 1 2"&gt; &lt;v:f eqn="prod @3 21600 pixelWidth"&gt; &lt;v:f eqn="prod @3 21600 pixelHeight"&gt; &lt;v:f eqn="sum @0 0 1"&gt; &lt;v:f eqn="prod @6 1 2"&gt; &lt;v:f eqn="prod @7 21600 pixelWidth"&gt; &lt;v:f eqn="sum @8 21600 0"&gt; &lt;v:f eqn="prod @7 21600 pixelHeight"&gt; &lt;v:f eqn="sum @10 21600 0"&gt; &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt; &lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt; &lt;o:lock v:ext="edit" aspectratio="t"&gt; &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;v:shape id="Picture_x0020_1" o:spid="_x0000_i1025" type="#_x0000_t75" style="width: 347.25pt; height: 231.75pt; visibility: visible; mso-wrap-style: square;"&gt; &lt;v:imagedata src="file:///D:\Temp\msohtmlclip1\01\clip_image001.png" o:title=""&gt; &lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="figcaption"&gt;Figure 1: Adding rows to a table using jQuery&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;body&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="container"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;lt;h1 class="text-center"&amp;gt;Add Row to Table (Hard-Coded)&amp;lt;/h1&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;lt;div class="row"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;lt;div class="center-block col-sm-6"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;table id="peopleTable" class="table table-bordered&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;table-condensed &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;table-striped"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;thead&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;th&amp;gt;First Name&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;th&amp;gt;Last Name&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;th&amp;gt;Email&amp;lt;/th&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/tr&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/thead&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/table&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/body&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="figcaption"&gt;&lt;img width="463" height="309" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/HTMLTables1.png" /&gt;&lt;/p&gt;
&lt;p class="figcaption"&gt;Figure 2: HTML Table Markup&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;h2&gt;Adding a Row&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;Within the &amp;lt;script&amp;gt; tag, create a function called addRows(). This function is where you will use the append() method to add a &amp;lt;tr&amp;gt; with the appropriate number of &amp;lt;td&amp;gt; tags to form a row for your table. Use a jQuery selector to locate the id attribute of your table, and the &amp;lt;tbody&amp;gt; tag and append a &amp;lt;tr&amp;gt; and the &amp;lt;td&amp;gt; tags as shown in the code below:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;function addRows() {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $("#peopleTable tbody").append(&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;tr&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;Paul&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;Sheriff&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;PSheriff@pdsa.com&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;/tr&amp;gt;"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; );&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;If you read the HTML I posted earlier, you will notice that I did not include a &amp;lt;tbody&amp;gt; tag within the table. So, if you were to run the addRows() function, then no rows will be appended to your table because the result of the selector comes back as nothing. First off, you really should always have a &amp;lt;tbody&amp;gt; in all of your tables. However, if you don&amp;rsquo;t, then no problem, you can always add one programmatically. First check to see if the selector of your table id and the &amp;lt;tbody&amp;gt; returns something. If it does not, then simply append a &amp;lt;tbody&amp;gt; tag to the table prior to calling the append() with the rows you wish to add. You do this with the code shown below:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;if ($("#peopleTable tbody").length == 0) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $("#peopleTable").append("&amp;lt;tbody&amp;gt;&amp;lt;/tbody&amp;gt;");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;So, our complete method to add a couple or rows to our HTML table, looks like the code shown below:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Add rows to &amp;lt;table&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; function addRows()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // First check if a &amp;lt;tbody&amp;gt; tag exists, add one if not&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($("#peopleTable tbody").length == 0) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#peopleTable").append("&amp;lt;tbody&amp;gt;&amp;lt;/tbody&amp;gt;");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Append row to the table&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#peopleTable tbody").append(&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;tr&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;Paul&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;Sheriff&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;PSheriff@pdsa.com&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;/tr&amp;gt;"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#peopleTable tbody").append(&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;tr&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;Michael&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;Krasowski&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;td&amp;gt;Michaelk@pdsa.com&amp;lt;/td&amp;gt;" +&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "&amp;lt;/tr&amp;gt;"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;You can call the above function when the document is loaded by adding the jQuery document.ready function just before the ending &amp;lt;/script&amp;gt; tag.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;$(document).ready(function () {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; addRows();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;});&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;In this blog post you learned how to add rows to an HTML table using JavaScript and jQuery. One important check you should always make is to find out if a &amp;lt;tbody&amp;gt; tag exists, and if it does not, then go ahead and add it. While you could just append rows directly to the table and not to the &amp;lt;tbody&amp;gt;, you are not guaranteed where those rows will be appended. On different browsers, this could cause issues. Using the method presented here always ensures your table is properly formed.&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</description><pubDate>Tue, 24 Feb 2015 15:13:30 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/manipulating-html-tables-%E2%80%93-part-1-adding-rows</guid><category>HTML</category><category>CSS</category><category>JavaScript</category><category>jQuery</category><category>Bootstrap</category></item><item><title>New Pluralsight Course Just Released</title><link>https://weblogs.asp.net:443/psheriff/new-pluralsight-course-just-released</link><description>&lt;p&gt;Hi All,&lt;/p&gt;
&lt;p&gt;I just had a new course published on Pluralsight. Check it out!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Build your own Bootstrap Business Application Template in MVC&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Creating your own bootstrap template that you can reuse across many applications is simple. In this course you will build up a collection of components that you build into an MVC application. You will create both horizontal and vertical data-driven menu systems. You will see some jQuery libraries that can add great functionality to your MVC apps. In addition you will learn when you should use a library versus when you should create your own. You will see a collection of cool UI widgets that are much smaller than those you will download on the web. You will see how to create tables that can sort and page data both client-side and server-side. Finally you will learn to build maintenance pages with search, add, edit, and delete capabilities all one a single page.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://pluralsight.com/Courses/bootstrap-business-application-template-mvc" title="Go to Pluralsight Course" target="_blank"&gt;http://pluralsight.com/Courses/bootstrap-business-application-template-mvc&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Promo Video: &lt;a href="http://www.pdsa.com/Plural_Sight/BootstrapTemplate-PromoVideo.mp4" title="Promotional Video" target="_blank"&gt;http://www.pdsa.com/Plural_Sight/BootstrapTemplate-PromoVideo.mp4&lt;/a&gt;&lt;/p&gt;</description><pubDate>Fri, 30 Jan 2015 15:48:18 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/new-pluralsight-course-just-released</guid><category>MVC</category><category>.NET</category><category>C#</category><category>Bootstrap</category><category>Pluralsight</category></item><item><title>Additions on a Bootstrap Panel</title><link>https://weblogs.asp.net:443/psheriff/additions-on-a-bootstrap-panel</link><description>&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Additions on a Bootstrap Panel&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;The Bootstrap panel classes allow you to create a bordered area on your web page. The panel classes give you a title area, a body area and a footer area. Most designers add buttons within the footer area to perform different actions on the information within the panel. Sometimes they add additional drop-downs or buttons within the body of the panel to reload the data or take action. While these work, sometimes you don&amp;rsquo;t want to take up that real estate with those actions. Instead you can use the title area of the panel for these additions. This blog post will show you how to accomplish this.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;Add a Reload Button&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;The first example you will learn is how to add on a &amp;lsquo;reload&amp;rsquo; button to the right-most area of the panel as seen in Figure 1.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;img width="507" height="416" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/Panel01.png" /&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt; &lt;v:stroke joinstyle="miter"&gt; &lt;v:formulas&gt; &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt; &lt;v:f eqn="sum @0 1 0"&gt; &lt;v:f eqn="sum 0 0 @1"&gt; &lt;v:f eqn="prod @2 1 2"&gt; &lt;v:f eqn="prod @3 21600 pixelWidth"&gt; &lt;v:f eqn="prod @3 21600 pixelHeight"&gt; &lt;v:f eqn="sum @0 0 1"&gt; &lt;v:f eqn="prod @6 1 2"&gt; &lt;v:f eqn="prod @7 21600 pixelWidth"&gt; &lt;v:f eqn="sum @8 21600 0"&gt; &lt;v:f eqn="prod @7 21600 pixelHeight"&gt; &lt;v:f eqn="sum @10 21600 0"&gt; &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt; &lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt; &lt;o:lock v:ext="edit" aspectratio="t"&gt; &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;v:shape id="Picture_x0020_3" o:spid="_x0000_i1026" type="#_x0000_t75" style="width: 380.4pt; height: 312pt; visibility: visible; mso-wrap-style: square;"&gt; &lt;v:imagedata src="file:///D:\Temp\msohtmlclip1\01\clip_image001.png" o:title=""&gt; &lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="figcaption"&gt;Figure 1: Add a Reload Button to the Panel&amp;rsquo;s Title area&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;To add this new button to the title, create an anchor tag within the &amp;lt;h1&amp;gt; or whatever HTML element you use for the panel title. I added a glyph from Bootstrap and the word &amp;ldquo;Reload&amp;rdquo; within this anchor tag. I then added one additional class called panel-right to that anchor tag as shown in the following code.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;div class="panel panel-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="panel-heading"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;h1 class="panel-title"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;span class="glyphicon glyphicon-music"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/span&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;nbsp;CountryMusic&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&amp;lt;a href="#" &lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="panel-right glyphicon glyphicon-random"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;nbsp;Reload&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/a&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/h1&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="panel-body"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Other HTML here&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;The &amp;ldquo;panel-right&amp;rdquo; class is very simple and is responsible for the look and feel of the button on the right side of the panel. You first add a border around the button and modify the border radius. Add a margin-top to position the button in the correct location. Modify the padding and font-size as appropriate. Finally set the float to right so the button stays on the right side of the panel. Turn off all text-decoration on the anchor tag so you don&amp;rsquo;t get any underline on the button. All of the styles shown below will be placed into a .CSS file that you can then add to any page where you wish to use panel additions.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;.panel-right {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;border: 0.05em solid lightgray;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;border-radius: 0.25em 0.25em;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;margin-top: -0.2em;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;padding: 0.3em;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;font-size: 0.9em;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;float: right;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .panel-title a,&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .panel-title a:active,&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .panel-title a:visited {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; text-decoration: none;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Drop Down in Panel&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;Another example of an addition you could add to a panel would be a drop-down selector as shown in Figure 2.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;img width="512" height="417" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/Panel02.png" /&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;v:shape id="Picture_x0020_1" o:spid="_x0000_i1025" type="#_x0000_t75" style="width: 384pt; height: 312.6pt; visibility: visible; mso-wrap-style: square;"&gt; &lt;v:imagedata src="file:///D:\Temp\msohtmlclip1\01\clip_image002.png" o:title=""&gt; &lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="figcaption"&gt;Figure 2: Adding a Drop-Down in the Panel Title Area&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;Adding a drop-down is a little different from a simple button as shown in the last example. You need a little more room within the panel-title so instead of an &amp;lt;h1&amp;gt; element use a &amp;lt;div&amp;gt;. This gives just a little more room within the panel-title. In addition you can&amp;rsquo;t nest a div tag within an h1, so we are forced to use this outer div element. Within the &amp;lt;div&amp;gt; element, place another &amp;lt;div&amp;gt; to contain the Bootstrap class &amp;lsquo;dropdown&amp;rsquo; and the panel-right class. Create your normal drop-down button as shown in the example that follows:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;div class="panel panel-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="panel-heading"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="panel-title"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;span class="glyphicon glyphicon-music"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/span&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;span &lt;b&gt;id="genre"&lt;/b&gt;&amp;gt;Country Music&amp;lt;/span&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;b&gt;&amp;lt;div class="dropdown panel-right"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;button class="btn btn-success"&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id="selectButton" &lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data-toggle="dropdown"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Change Genre&amp;amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;span class="caret"&amp;gt;&amp;lt;/span&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/button&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ul class="dropdown-menu" id="ulGenres"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;li&amp;gt;&amp;lt;a href="#"&amp;gt;Jazz&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;li&amp;gt;&amp;lt;a href="#"&amp;gt;Country&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;li&amp;gt;&amp;lt;a href="#"&amp;gt;Rock&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/ul&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="panel-body"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Other HTML here&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;The style you use for the panel-right is a little different from the previous example. You need a different margin-top and you need to turn off the border. So on this page you will include the .CSS file you created with the previous styles, then after this &amp;lt;link&amp;gt; you add the following styles to override the ones in the .CSS file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;link href="~/Content/pdsa-panel-additions.css"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;rel="stylesheet" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;lt;style&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .panel-right {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; border: none;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; margin-top: -0.65em;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/style&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;When you select an item from the drop-down selector you should change the title on the panel. You can use a little jQuery code to accomplish this. Add the following script at the bottom of your page to modify the text within the panel title when the user clicks on an item in the drop-down selector.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $(document).ready(function () {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#ulGenres li a").on("click", function () {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var text = $(this).text();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#genre").text(text + ' Music');&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; });&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;In this blog post you learned how to add some additions to the Bootstrap panel classes. Using the right side of the panel is a great way to allow your user to perform actions within the panel without taking up valuable real estate within the panel itself.&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</description><pubDate>Wed, 31 Dec 2014 18:09:17 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/additions-on-a-bootstrap-panel</guid><category>Bootstrap</category><category>MVC</category><category>jQuery</category><category>panel classes</category></item><item><title>Displaying a Wait Message on an MVC Page</title><link>https://weblogs.asp.net:443/psheriff/displaying-a-wait-message-on-an-mvc-page</link><description>&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 6pt 0in 6pt 0.75in;"&gt;&lt;span style="background: white; mso-highlight: white;"&gt;&lt;span style="font-family: Arial; font-size: medium;" size="3" face="Arial"&gt;&amp;nbsp; When a user clicks on a button on a web page, there can be a delay between posting back to the server and the next action that happens on the screen. The problem with this delay is the user may not know they actually clicked on the button and tries to hit the button again. It is important to give immediate feedback to the user so they know that the application is doing something. This post will show you how to disable the button, display a pop-up message and gray out the background before the post back happens thereby providing feedback to our user.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;h2 style="margin: 60pt 0in 0.25in;"&gt;&lt;span style="font-family: Arial; font-size: xx-large;" size="6" face="Arial"&gt;A Save Screen&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 6pt 0in 6pt 0.75in;"&gt;&lt;span style="font-family: Arial; font-size: medium;" size="3" face="Arial"&gt;In Figure 1 is a screen where the user might fill in some data, then post that data back to the server to save in a database. When the user clicks on the Save button you will add the &amp;lsquo;disabled&amp;rsquo; property to the button, change the text of the button, pop-up a message in the middle of the screen and gray out the background as shown in Figure 2.&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 6pt 0in 6pt 0.75in;"&gt;&lt;span style="font-family: Arial; font-size: medium;" size="3" face="Arial"&gt;&lt;img width="606" height="421" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/WaitScreen1.png" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 12pt 0in 6pt 0.5in;"&gt;&lt;span style="mso-no-proof: yes;"&gt;&lt;v:shapetype id="_x0000_t75" stroked="f" filled="f" path="m@4@5l@4@11@9@11@9@5xe" o:preferrelative="t" o:spt="75" coordsize="21600,21600"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Arial;" face="Arial"&gt; &lt;v:stroke joinstyle="miter"&gt; &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt; &lt;v:f eqn="sum @0 1 0"&gt; &lt;v:f eqn="sum 0 0 @1"&gt; &lt;v:f eqn="prod @2 1 2"&gt; &lt;v:f eqn="prod @3 21600 pixelWidth"&gt; &lt;v:f eqn="prod @3 21600 pixelHeight"&gt; &lt;v:f eqn="sum @0 0 1"&gt; &lt;v:f eqn="prod @6 1 2"&gt; &lt;v:f eqn="prod @7 21600 pixelWidth"&gt; &lt;v:f eqn="sum @8 21600 0"&gt; &lt;v:f eqn="prod @7 21600 pixelHeight"&gt; &lt;v:f eqn="sum @10 21600 0"&gt; &lt;/v:f&gt; &lt;v:path o:connecttype="rect" gradientshapeok="t" o:extrusionok="f"&gt; &lt;o:lock aspectratio="t" v:ext="edit"&gt; &lt;/o:lock&gt;&lt;v:shape id="Picture_x0020_2" style="width: 426.75pt; height: 296.25pt; visibility: visible; mso-wrap-style: square;" type="#_x0000_t75" o:spid="_x0000_i1026"&gt; &lt;v:imagedata o:title="" src="file:///D:\Temp\msohtmlclip1\01\clip_image001.png"&gt; &lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;/v:path&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:stroke&gt;&lt;/span&gt;&lt;/span&gt;&lt;/v:shapetype&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0.3in 0.25in 1.1in;"&gt;&lt;span style="font-family: Tahoma; font-size: small;" size="2" face="Tahoma"&gt;Figure 1: A sample screen that will perform some processing.&lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0.3in 0.25in 1.1in;"&gt;&lt;span style="font-family: Tahoma; font-size: small;" size="2" face="Tahoma"&gt; &lt;img width="573" height="398" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/WaitScreen2.png" /&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 12pt 0in 6pt 0.5in;"&gt;&lt;span style="mso-no-proof: yes;"&gt;&lt;v:shape id="Picture_x0020_1" style="width: 429.75pt; height: 298.5pt; visibility: visible; mso-wrap-style: square;" type="#_x0000_t75" o:spid="_x0000_i1025"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Arial;" face="Arial"&gt; &lt;v:imagedata o:title="" src="file:///D:\Temp\msohtmlclip1\01\clip_image002.png"&gt; &lt;/v:imagedata&gt;&lt;/span&gt;&lt;/span&gt;&lt;/v:shape&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 0in 0.3in 0.25in 1.1in;"&gt;&lt;span style="font-family: Tahoma; font-size: small;" size="2" face="Tahoma"&gt;Figure 2: Give the user feedback that something is happening.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;h2 style="margin: 60pt 0in 0.25in;"&gt;&lt;span style="font-family: Arial; font-size: xx-large;" size="6" face="Arial"&gt;Changing the Button on Click&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 6pt 0in 6pt 0.75in;"&gt;&lt;span style="font-family: Arial; font-size: medium;" size="3" face="Arial"&gt;The first step is to create a simple JavaScript function that can be called from the onclick event of the Save button.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;div style="padding: 4pt; border: 1.5pt double silver; margin-right: 0.3in; margin-left: 1in; mso-element: para-border-div;"&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0.25in 0in 0pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;&amp;lt;button type="submit"&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;id="submitButton"&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;class="btn btn-primary"&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;onclick="return &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;DisplayProgressMessage(this, 'Saving...');"&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;Save&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 12pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 6pt 0in 6pt 0.75in;"&gt;&lt;span style="font-family: Arial; font-size: medium;" size="3" face="Arial"&gt;The DisplayProgressMessage first has to add the &amp;lsquo;disabled&amp;rsquo; property to the button, then change the text of the button from &amp;lsquo;Save&amp;rsquo; to &amp;lsquo;Saving&amp;hellip;&amp;rsquo;. Notice that you pass &amp;lsquo;this&amp;rsquo; and the text &amp;lsquo;Saving&amp;hellip;&amp;rsquo; to the DisplayProgressMessage. Here is the first pass at our DisplayProgressMessage function:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;div style="padding: 4pt; border: 1.5pt double silver; margin-right: 0.3in; margin-left: 1in; mso-element: para-border-div;"&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0.25in 0in 0pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;function DisplayProgressMessage(ctl, msg) {&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;$(ctl).prop("disabled", true);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;$(ctl).text(msg);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;return true;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 12pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;h2 style="margin: 60pt 0in 0.25in;"&gt;&lt;span style="font-family: Arial; font-size: xx-large;" size="6" face="Arial"&gt;Add Pop-Up Message&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 6pt 0in 6pt 0.75in;"&gt;&lt;span style="font-family: Arial; font-size: medium;" size="3" face="Arial"&gt;Add a pop-up message by creating a &amp;lt;div&amp;gt; with a &amp;lt;label&amp;gt; in it. Within the label, place the text you wish to display. Add a CSS class called &amp;lsquo;submit-progress&amp;rsquo; to style the pop-up message. Set this &amp;lt;div&amp;gt; as hidden so it won&amp;rsquo;t show up until you want it to.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;div style="padding: 4pt; border: 1.5pt double silver; margin-right: 0.3in; margin-left: 1in; mso-element: para-border-div;"&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0.25in 0in 0pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;&amp;lt;div class="submit-progress hidden"&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;label&amp;gt;Please wait while Saving Data...&amp;lt;/label&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 12pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 6pt 0in 6pt 0.75in;"&gt;&lt;span style="font-family: Arial; font-size: medium;" size="3" face="Arial"&gt;Create the &lt;b style="mso-bidi-font-weight: normal;"&gt;submit-progress&lt;/b&gt; style using a fixed position on the screen. You will set the top and left to 50% to place this &amp;lt;div&amp;gt; in the middle of the page. Set some padding, width and margins that are appropriate for the message you are displaying. Also select a background and foreground color.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;div style="padding: 4pt; border: 1.5pt double silver; margin-right: 0.3in; margin-left: 1in; mso-element: para-border-div;"&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0.25in 0in 0pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;.submit-progress {&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;position: fixed;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;top: 50%;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;left: 50%;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;height: 6em;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;padding-top: 2.3em;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;/* The following rules are the ones most likely to change */&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;width: 20em;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;/* Set 'margin-left' to a negative number &lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;that is 1/2 of 'width' */&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;margin-left: -10em;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;padding-left: 2.1em;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;background-color: black;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&lt;/span&gt;color: white;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 12pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 6pt 0in 6pt 0.75in;"&gt;&lt;span style="font-family: Arial; font-size: medium;" size="3" face="Arial"&gt;Now update the DisplayProgressMessage function to display this message when the button is clicked:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;div style="padding: 4pt; border: 1.5pt double silver; margin-right: 0.3in; margin-left: 1in; mso-element: para-border-div;"&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0.25in 0in 0pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;function DisplayProgressMessage(ctl, msg) {&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;$(ctl).prop("disabled", true).text(msg);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;$(".submit-progress").removeClass("hidden");&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;return true;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 12pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 6pt 0in 6pt 0.75in;"&gt;&lt;span style="font-family: Arial; font-size: medium;" size="3" face="Arial"&gt;Notice in the above code that I chained the setting of the disabled property and the setting of the text on the button. This is not absolutely necessary, but it is a little more efficient as the selector only needs to be called one time.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;h2 style="margin: 60pt 0in 0.25in;"&gt;&lt;span style="font-family: Arial; font-size: xx-large;" size="6" face="Arial"&gt;Gray Out the Background&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 6pt 0in 6pt 0.75in;"&gt;&lt;span style="font-family: Arial; font-size: medium;" size="3" face="Arial"&gt;To provide even more feedback to the user that something is happening when they click on the button, you might gray out the whole web page. This is accomplished by applying a background color of &amp;lsquo;lightgray&amp;rsquo; and an opacity of 50% to the &amp;lt;body&amp;gt; element. To do this add a style to your page that you can add to the &amp;lt;body&amp;gt; using JavaScript.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;div style="padding: 4pt; border: 1.5pt double silver; margin-right: 0.3in; margin-left: 1in; mso-element: para-border-div;"&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0.25in 0in 0pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;.submit-progress-bg {&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;background-color: lightgray;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;opacity: .5;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 12pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 6pt 0in 6pt 0.75in;"&gt;&lt;span style="font-family: Arial; font-size: medium;" size="3" face="Arial"&gt;Change your DisplayProgressMessage to add this class to the &amp;lt;body&amp;gt; tag when the button is clicked.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;div style="padding: 4pt; border: 1.5pt double silver; margin-right: 0.3in; margin-left: 1in; mso-element: para-border-div;"&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0.25in 0in 0pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;&amp;lt;script&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;function DisplayProgressMessage(ctl, msg) {&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;$(ctl).prop("disabled", true);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;$(ctl).text(msg);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;$(".submit-progress").removeClass("hidden");&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal;"&gt;$("body").addClass("submit-progress-bg");&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;return true;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 0pt;"&gt;&lt;span style="font-size: small;" size="2"&gt;&lt;span style="font-family: Courier New;" face="Courier New"&gt;&lt;span style="mso-spacerun: yes;"&gt;&amp;nbsp; &lt;/span&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;
&lt;p style="margin: 0in 0in 12pt;"&gt;&lt;span style="font-family: Courier New; font-size: small;" size="2" face="Courier New"&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;h2 style="margin: 60pt 0in 0.25in;"&gt;&lt;span style="font-family: Arial; font-size: xx-large;" size="6" face="Arial"&gt;Summary&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p style="margin: 6pt 0in 6pt 0.75in;"&gt;&lt;span style="font-family: Arial; font-size: medium;" size="3" face="Arial"&gt;In this blog post you saw how easy it is to add some feedback to your user when they are about to call a long operation on the server. It is important to provide the feedback so they don&amp;rsquo;t try to click on the same button again, or try to navigate somewhere else while you are finishing a process. I am sure you can expand upon the idea presented in this article and apply it to your specific use cases.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: Times New Roman; font-size: medium;" size="3" face="Times New Roman"&gt; &lt;/span&gt;&lt;/p&gt;</description><pubDate>Tue, 23 Dec 2014 19:01:25 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/displaying-a-wait-message-on-an-mvc-page</guid><category>MVC</category><category>jQuery</category><category>CSS</category><category>Wait Message</category></item><item><title>A Simple Bootstrap Radio Button for MVC</title><link>https://weblogs.asp.net:443/psheriff/a-simple-bootstrap-radio-button-for-mvc</link><description>&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;A Simple Bootstrap Radio Button for MVC&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;In a previous blog post I talked about a simple push button style of radio buttones. This sample push button style can be applied to radio buttons too. This style of button is very easy to do with just some built-in Bootstrap styles and a little extra CSS.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;h2&gt;Simple Radio Button&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;As a way to get a better looking radio button, you can wrap a radio button into a button as shown in Figure 1. What is nice about this style of radio button is it wraps the label together with the radio button. In addition, on a mobile device it is much easier to press as the whole button area is clickable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;img width="358" height="176" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/SimpleRadioButton.png" /&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;Figure 1: Radio buttons wrapped into a button&lt;/p&gt;
&lt;p class="figcaption"&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;To create these radio buttones you wrap the radio button within the normal Bootstrap class &amp;ldquo;checkbox&amp;rdquo;. You then add a label element with the classes &amp;ldquo;btn btn-default&amp;rdquo; around the radio button as shown in the following code:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@using (Html.BeginForm())&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="well well-sm"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="radio"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-default"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.RadioButton("gender", "Male", &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; true, new { id = "IsMale" })&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Male&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="radio"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-default"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.RadioButton("gender", "Female",&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new { id = "IsFemale" })&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Female&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;To make it appear correctly, you have to add the following CSS to align the radio button and the text correctly within the button. That is all there is to it!&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;style&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .radio .btn,&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .radio-inline .btn {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; padding-left: 2em;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; min-width: 7em;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .radio label,&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .radio-inline label {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; text-align: left;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/style&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p&gt;Creating better looking controls for your web page is sometimes very simple and just involves combing a couple of elements together along with a tiny bit of CSS.&lt;/p&gt;</description><pubDate>Fri, 05 Dec 2014 09:03:30 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/a-simple-bootstrap-radio-button-for-mvc</guid><category>MVC</category><category>Bootstrap</category><category>.NET</category><category>CSS</category></item><item><title>A Simple Bootstrap Check Box for MVC</title><link>https://weblogs.asp.net:443/psheriff/a-simple-bootstrap-check-box-for-mvc</link><description>&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;A Simple Bootstrap Check Box for MVC&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;I really enjoy working with Bootstrap and extending the styles to match what my customers want. Recently my customer wanted a simple push button style of check box and radio buttons. This turned out to be very easy to accomplish using the built-in Bootstrap styles and just a little extra CSS.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;h2&gt;Simple Check Box&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;As a way to get a better looking check box, you can wrap a check box into a button as shown in Figure 1. What is nice about this style of check box is it really puts the label together with the check box. In addition, on a mobile device it is much easier to hit as the whole button area is clickable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;img width="348" height="220" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/SimpleCheckBox.png" /&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;/p&gt;
&lt;p class="figcaption"&gt;Figure 1: Check boxes wrapped into a button&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;To create these check boxes you simply have to wrap the check box within the normal Bootstrap class &amp;ldquo;checkbox&amp;rdquo;. You then add a label element with the classes &amp;ldquo;btn btn-default&amp;rdquo; around the check box as shown in the following code:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@using (Html.BeginForm())&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="well well-sm"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="checkbox"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-default"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.CheckBox("IsJazz")&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jazz&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="checkbox"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-default"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.CheckBox("IsCountry")&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Country&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="checkbox"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-default"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.CheckBox("IsRock")&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Rock&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;To make it appear correctly, you have to add the following CSS to align the check box and the text correctly within the button. That is all there is to it!&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;style&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .checkbox .btn,&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .checkbox-inline .btn {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; padding-left: 2em;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; min-width: 7em;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .checkbox label,&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .checkbox-inline label {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; text-align: left;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/style&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Creating better looking controls for your web page is sometimes very simple and just involves combing a couple of elements together along with a tiny bit of CSS.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</description><pubDate>Wed, 03 Dec 2014 09:03:20 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/a-simple-bootstrap-check-box-for-mvc</guid><category>MVC</category><category>bootstrap</category><category>.net</category><category>CSS</category></item><item><title>A Simple Bootstrap Radio Button for Web Forms</title><link>https://weblogs.asp.net:443/psheriff/a-simple-bootstrap-radio-button-for-web-forms</link><description>&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;A Simple Bootstrap Radio Button for Web Forms&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;In a previous post I talked about creating a push-button style of radio button for MVC. This blog post will show how to create the same push-button radio button using Web Forms. There are only a few minor differences in the CSS and, of course, in the use of a Web Forms server control.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;h2&gt;Simple Radio Button&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;As a way to get a better looking radio button, you can wrap a radio button into a button as shown in Figure 1. What is nice about this style of radio button is it wraps the label together with the radio button. In addition, on a mobile device it is much easier to press as the whole button area is clickable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;img width="358" height="176" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/SimpleRadioButton.png" /&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt; &lt;v:stroke joinstyle="miter"&gt; &lt;v:formulas&gt; &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt; &lt;v:f eqn="sum @0 1 0"&gt; &lt;v:f eqn="sum 0 0 @1"&gt; &lt;v:f eqn="prod @2 1 2"&gt; &lt;v:f eqn="prod @3 21600 pixelWidth"&gt; &lt;v:f eqn="prod @3 21600 pixelHeight"&gt; &lt;v:f eqn="sum @0 0 1"&gt; &lt;v:f eqn="prod @6 1 2"&gt; &lt;v:f eqn="prod @7 21600 pixelWidth"&gt; &lt;v:f eqn="sum @8 21600 0"&gt; &lt;v:f eqn="prod @7 21600 pixelHeight"&gt; &lt;v:f eqn="sum @10 21600 0"&gt; &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt; &lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt; &lt;o:lock v:ext="edit" aspectratio="t"&gt; &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;v:shape id="Picture_x0020_3" o:spid="_x0000_i1025" type="#_x0000_t75" style="width: 268.5pt; height: 132pt; visibility: visible; mso-wrap-style: square;"&gt; &lt;v:imagedata src="file:///D:\Temp\msohtmlclip1\01\clip_image001.png" o:title=""&gt; &lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="figcaption"&gt;Figure 1: Radio buttons wrapped into a button&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;To create these radio buttones you wrap the radio button within the normal Bootstrap class &amp;ldquo;checkbox&amp;rdquo;. You then add a label element with the classes &amp;ldquo;btn btn-default&amp;rdquo; around the radio button as shown in the following code:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="radio"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-default"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:RadioButton ID="IsMale" runat="server"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GroupName="gender"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Checked="true"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Text="Male" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="radio"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-default"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:RadioButton ID="IsFemale" runat="server"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GroupName="gender"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Text="Female" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;To make it appear correctly, you have to add the following CSS to align the radio button and the text correctly within the button. That is all there is to it!&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;style&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .radio .btn,&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .radio-inline .btn {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; padding-left: 2em;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; min-width: 7em;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .radio label,&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .radio-inline label {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; text-align: left;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; padding-left: 0.5em;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/style&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;Creating better looking controls for your web page is sometimes very simple and just involves combing a couple of elements together along with a tiny bit of CSS.&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</description><pubDate>Wed, 03 Dec 2014 00:55:03 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/a-simple-bootstrap-radio-button-for-web-forms</guid><category>Bootstrap</category><category>web forms</category><category>asp.net</category><category>c#</category><category>radio buttons</category></item><item><title>A Simple Bootstrap Check Box for Web Forms</title><link>https://weblogs.asp.net:443/psheriff/a-simple-bootstrap-check-box-for-web-forms</link><description>&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;A Simple Bootstrap Check Box for Web Forms&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;In a previous post I talked about creating a push-button style of check box for MVC. This blog post will show how to create the same push-button check box using Web Forms. There are only a few minor differences in the CSS and, of course, in the use of a Web Forms server control.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;h2&gt;Simple Check Box&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;As a way to get a better looking check box, you can wrap a check box into a button as shown in Figure 1. What is nice about this style of check box is it really puts the label together with the check box. In addition, on a mobile device it is much easier to hit as the whole button area is clickable.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;img width="348" height="220" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/SimpleCheckBox.png" /&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt; &lt;v:stroke joinstyle="miter"&gt; &lt;v:formulas&gt; &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt; &lt;v:f eqn="sum @0 1 0"&gt; &lt;v:f eqn="sum 0 0 @1"&gt; &lt;v:f eqn="prod @2 1 2"&gt; &lt;v:f eqn="prod @3 21600 pixelWidth"&gt; &lt;v:f eqn="prod @3 21600 pixelHeight"&gt; &lt;v:f eqn="sum @0 0 1"&gt; &lt;v:f eqn="prod @6 1 2"&gt; &lt;v:f eqn="prod @7 21600 pixelWidth"&gt; &lt;v:f eqn="sum @8 21600 0"&gt; &lt;v:f eqn="prod @7 21600 pixelHeight"&gt; &lt;v:f eqn="sum @10 21600 0"&gt; &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt; &lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt; &lt;o:lock v:ext="edit" aspectratio="t"&gt; &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;v:shape id="Picture_x0020_1" o:spid="_x0000_i1025" type="#_x0000_t75" style="width: 261pt; height: 165pt; visibility: visible; mso-wrap-style: square;"&gt; &lt;v:imagedata src="file:///D:\Temp\msohtmlclip1\01\clip_image001.png" o:title=""&gt; &lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="figcaption"&gt;Figure 1: Check boxes wrapped into a button&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;To create these check boxes you simply have to wrap the check box within the normal Bootstrap class &amp;ldquo;checkbox&amp;rdquo;. You then add a label element with the classes &amp;ldquo;btn btn-default&amp;rdquo; around the check box as shown in the following code:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="checkbox"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-default"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:CheckBox ID="IsJazz" runat="server" &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Text="Jazz" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="checkbox"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-default"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:CheckBox ID="IsCountry" runat="server" &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Text="Country" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="checkbox"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-default"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;asp:CheckBox ID="IsRock" runat="server"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;Text="Rock" /&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;To make it appear correctly, you have to add the following CSS to align the check box and the text correctly within the button. That is all there is to it!&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;style&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .checkbox .btn,&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .checkbox-inline .btn {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; padding-left: 2em;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; min-width: 8em;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .checkbox label,&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .checkbox-inline label {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; text-align: left;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; padding-left: 0.5em;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/style&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Creating better looking controls for your web page is sometimes very simple and just involves combing a couple of elements together along with a tiny bit of CSS.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</description><pubDate>Wed, 03 Dec 2014 00:50:05 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/a-simple-bootstrap-check-box-for-web-forms</guid><category>Bootstrap</category><category>web forms</category><category>check box</category><category>c#</category><category>ASP.NET</category></item><item><title>Bind Custom Radio Buttons to Integer Data</title><link>https://weblogs.asp.net:443/psheriff/bind-custom-radio-buttons-to-integer-data</link><description>&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Bind Custom Radio Buttons to Integer Data&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;In the last blog post I showed you how to bind radio buttons to a boolean value. In this blog post we will look at how to bind to integer values. In certain business applications you might have the user select a single value from a list of items coming from a database. You want to display these options as radio buttons and then retrieve the value the user selects.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;h2&gt;Create List of Radio Buttons&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;If you look at Figure 1 you see a row of radio buttons using the custom look I created a few blog posts ago. This set of radio buttons comes from a collection of MusicGenre objects. Each MusicGenre class contains a GenreId and Genre property. GenreId is an integer value that represents the primary key. Genre is the string value such as &amp;lsquo;Jazz&amp;rsquo;, &amp;lsquo;Rock&amp;rsquo;, &amp;lsquo;Blues&amp;rsquo;, etc.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;img width="503" height="286" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/BootstrapRadioButton5.png" /&gt;&lt;/p&gt;
&lt;p class="ScrShotWide"&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt; &lt;v:stroke joinstyle="miter"&gt; &lt;v:formulas&gt; &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt; &lt;v:f eqn="sum @0 1 0"&gt; &lt;v:f eqn="sum 0 0 @1"&gt; &lt;v:f eqn="prod @2 1 2"&gt; &lt;v:f eqn="prod @3 21600 pixelWidth"&gt; &lt;v:f eqn="prod @3 21600 pixelHeight"&gt; &lt;v:f eqn="sum @0 0 1"&gt; &lt;v:f eqn="prod @6 1 2"&gt; &lt;v:f eqn="prod @7 21600 pixelWidth"&gt; &lt;v:f eqn="sum @8 21600 0"&gt; &lt;v:f eqn="prod @7 21600 pixelHeight"&gt; &lt;v:f eqn="sum @10 21600 0"&gt; &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt; &lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt; &lt;o:lock v:ext="edit" aspectratio="t"&gt; &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;v:shape id="Picture_x0020_2" o:spid="_x0000_i1025" type="#_x0000_t75" style="width: 376.5pt; height: 214.5pt; visibility: visible; mso-wrap-style: square;"&gt; &lt;v:imagedata src="file:///D:\Temp\msohtmlclip1\01\clip_image001.png" o:title=""&gt; &lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="figcaption"&gt;Figure 1: A list of Radio Buttons&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;h3&gt;The MusicGenre Entity Class&lt;o:p&gt;&lt;/o:p&gt;&lt;/h3&gt;
&lt;p class="MsoBodyText"&gt;To create the list of radio buttons in Figure 1, you first need a MusicGenre class as shown in the listing below:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;public class MusicGenre&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public MusicGenre()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GenreId = 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genre = string.Empty;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;span lang="FR-CA"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;span lang="FR-CA"&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;span lang="FR-CA"&gt;&amp;nbsp; public MusicGenre(int id, string genre)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;span lang="FR-CA"&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;span lang="FR-CA"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GenreId = id;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;span lang="FR-CA"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genre = genre;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public int GenreId { get; set; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public string Genre {get;set;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h3&gt;Create a Manager Class&lt;o:p&gt;&lt;/o:p&gt;&lt;/h3&gt;
&lt;p class="MsoBodyText"&gt;Next you create a &amp;ldquo;Manager&amp;rdquo; class to create the collection of MusicGenre objects. In this blog post you will use some mock data, but you could replace this with data from a real database table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;public partial class MusicGenreManager&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public MusicGenreManager()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genres = new List&amp;lt;MusicGenre&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LoadAllMock();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public List&amp;lt;MusicGenre&amp;gt; Genres { get; set; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; protected void LoadAllMock()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genres.Add(new MusicGenre(1, "Jazz"));&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genres.Add(new MusicGenre(2, "Country"));&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genres.Add(new MusicGenre(3, "Rock"));&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genres.Add(new MusicGenre(4, "Blues")); &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genres.Add(new MusicGenre(5, "Alternative Rock"));&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h3&gt;Create a View Model&lt;o:p&gt;&lt;/o:p&gt;&lt;/h3&gt;
&lt;p class="MsoBodyText"&gt;Now that you have these two classes created, create a View Model class that you can use from the Controller in our MVC application. This View Model class simply uses the two previous classes to populate a &amp;lsquo;Genres&amp;rsquo; property that is a generic list of MusicGenre objects. We will also create one additional property in the View Model class to which to bind the selected genre id.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;public class MusicGenreViewModel&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public MusicGenreViewModel()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;span lang="FR-CA"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;span lang="FR-CA"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genres = new List&amp;lt;MusicGenre&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;span lang="FR-CA"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LoadGenres();&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;span lang="FR-CA"&gt;&amp;nbsp; &lt;/span&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public List&amp;lt;MusicGenre&amp;gt; Genres { get; set; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public int SelectedId { get; set; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public void LoadGenres()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; MusicGenreManager mgr = new MusicGenreManager();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Get list of Music Genres&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genres = mgr.Genres;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h3&gt;Create a View&lt;o:p&gt;&lt;/o:p&gt;&lt;/h3&gt;
&lt;p class="MsoBodyText"&gt;Create a .cshtml view page that will use the MusicGenreViewModel class that holds the list of MusicGenre objects. At the top of your view add the @model statement to specify you will be using the view model class. I added a little styling to provide some separation between each of the radio buttons.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@model BootstrapRadio2.MusicGenreViewModel&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;@{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; ViewBag.Title = "Data-Driven Radio Buttons";&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;lt;style&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .pdsa-radiobutton {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; margin-right: .5em;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; text-align: left;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/style&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;Next you use the BeginForm statement to wrap all of the radio buttons and a submit button within a &amp;lt;form&amp;gt; tag. Notice that the RadioButtonFor() helper is binding to the SelectedId property in the View Model. If you select a radio button on the form and click the submit button, the GenreId from the 2&lt;sup&gt;nd&lt;/sup&gt; parameter to the RadioButtonFor() helper is moved into the SelectedId property.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@using (Html.BeginForm())&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="well well-sm"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;h3&amp;gt;Data-Driven Radio Buttons&amp;lt;/h3&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="btn-group" data-toggle="buttons" id="genre"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @foreach (var item in Model.Genres)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="pdsa-radiobutton btn btn-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;span class="glyphicon glyphicon-unchecked"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/span&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.RadioButtonFor(m =&amp;gt; m.SelectedId, &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; item.GenreId, &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new { id = item.GenreId })&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @item.Genre&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;button type="submit" &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="btn btn-success"&amp;gt;Submit&amp;lt;/button&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h3&gt;Create the Controller&lt;o:p&gt;&lt;/o:p&gt;&lt;/h3&gt;
&lt;p class="MsoBodyText"&gt;Let&amp;rsquo;s now create the controller to instantiate an instance of the MusicGenreViewModel class and pass that instance to the view.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;public ActionResult Radio07()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; MusicGenreViewModel vm = new MusicGenreViewModel();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; return View(vm);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Retrieve the Value Selected&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;Once you select a radio button and click on the Submit button you post back to another controller action as shown below. The SelectedId property is automatically bound to the view model class. All you have to do to retrieve the appropriate MusicGenre object is loop through the list of MusicGenre objects and find where the selected id matched the GenreId. You can accomplish this with the Find() method on the collection class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;[HttpPost]&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;public ActionResult Radio07(MusicGenreViewModel vm)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; MusicGenre entity;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; entity = vm.Genres.Find(g =&amp;gt; g.GenreId == vm.SelectedId);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; System.Diagnostics.Debugger.Break();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; return View(vm);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;This blog post showed you how to bind a set of radio buttons to a set of objects with a unique ID. This simulates using data coming from a database table with an integer primary key.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</description><pubDate>Mon, 01 Dec 2014 23:28:12 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/bind-custom-radio-buttons-to-integer-data</guid><category>MVC</category><category>.NET</category><category>C#</category><category>Radio Buttons</category></item><item><title>Bind Custom Radio Buttons to True/False Property</title><link>https://weblogs.asp.net:443/psheriff/bind-custom-radio-buttons-to-true-false-property</link><description>&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Bind Custom Radio Buttons to True/False Property&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;In the last blog post I showed you how to create a different look and feel for radio buttons. We used the button groups and glyph icons from bootstrap to build this different look. Now let&amp;rsquo;s bind these radio buttons to a single boolean property in a class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;Let&amp;rsquo;s say you have a Product class that has an IsDiscontinued property that you would like a user to select between an &amp;ldquo;Active&amp;rdquo; and a &amp;ldquo;Discontinued&amp;rdquo; product. You might design the screen to look like Figure 1.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;img width="422" height="329" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/BootstrapRadioButton4.png" /&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt; &lt;v:stroke joinstyle="miter"&gt; &lt;v:formulas&gt; &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt; &lt;v:f eqn="sum @0 1 0"&gt; &lt;v:f eqn="sum 0 0 @1"&gt; &lt;v:f eqn="prod @2 1 2"&gt; &lt;v:f eqn="prod @3 21600 pixelWidth"&gt; &lt;v:f eqn="prod @3 21600 pixelHeight"&gt; &lt;v:f eqn="sum @0 0 1"&gt; &lt;v:f eqn="prod @6 1 2"&gt; &lt;v:f eqn="prod @7 21600 pixelWidth"&gt; &lt;v:f eqn="sum @8 21600 0"&gt; &lt;v:f eqn="prod @7 21600 pixelHeight"&gt; &lt;v:f eqn="sum @10 21600 0"&gt; &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt; &lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt; &lt;o:lock v:ext="edit" aspectratio="t"&gt; &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;v:shape id="Picture_x0020_1" o:spid="_x0000_i1025" type="#_x0000_t75" style="width: 316.5pt; height: 246.75pt; visibility: visible; mso-wrap-style: square;"&gt; &lt;v:imagedata src="file:///D:\Temp\msohtmlclip1\01\clip_image001.png" o:title=""&gt; &lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="figcaption"&gt;Figure 1: Choose between two Boolean states.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;To build this screen you first create your Product class. The code below shows an example Product class. The IsDiscontinued property is the property you bind to.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;namespace BootstrapRadio2&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public partial class Product&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public int ProductId { get; set; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string ProductName { get; set; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public decimal Price { get; set; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public bool IsDiscontinued { get; set; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;Create your cshtml view and specify the name of the model to use at the top of the file. I also added a little styling to a class called pdsa-radiobutton that puts a little spacing between the two radio buttons.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@model BootstrapRadio2.Product&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;@{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; ViewBag.Title = "Get/Set Values from Model";&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;lt;style&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; .pdsa-radiobutton {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; margin-right: .5em;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; text-align: left;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/style&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;Build your view using the Html.BeginForm() helper to emit a &amp;lt;form&amp;gt; tag. Create a &amp;ldquo;form-group&amp;rdquo; into which you put a &amp;ldquo;btn-group&amp;rdquo;. If you are not familiar with button groups in Bootstrap you should look at &lt;a href="http://www.getbootstrap.com/"&gt;www.getbootstrap.com&lt;/a&gt; for more information. The &amp;lt;label&amp;gt;, and &amp;lt;span&amp;gt; tags should be self-explanatory, especially if you read my first blog post on creating these types of radio buttons.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;The next item you need is to bind the IsDiscontinued property to an HTML radio button. You use the @HtmlRadioButtonFor() helper to do this binding. The first parameter to this helper is the expression to bind to the product in the model. The second parameter is the value to return to the model if this button is chosen. The third parameter is a collection of other attributes you wish to be emitted into the HTML. Lastly we need a submit button to post the data back to our controller.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@using (Html.BeginForm())&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;h3&amp;gt;Get/Set Values from Model&amp;lt;/h3&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="btn-group" data-toggle="buttons" id="product"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="pdsa-radiobutton btn btn-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;span class="glyphicon glyphicon-unchecked"&amp;gt;&amp;lt;/span&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.RadioButtonFor(m =&amp;gt; m.IsDiscontinued, "false",&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new { id = "IsActive" }) Is Active?&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="pdsa-radiobutton btn btn-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;span class="glyphicon glyphicon-unchecked"&amp;gt;&amp;lt;/span&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.RadioButtonFor(m =&amp;gt; m.IsDiscontinued, "true",&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new { id = "IsDiscontinued" }) Is Discontinued?&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;button type="submit" &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="btn btn-success"&amp;gt;Submit&amp;lt;/button&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h3&gt;The Controller&lt;o:p&gt;&lt;/o:p&gt;&lt;/h3&gt;
&lt;p class="MsoBodyText"&gt;There are two methods you add to the controller for this view. First is the GET method, defined here as &amp;ldquo;Radio06&amp;rdquo;. This method creates a new instance of the Product class and sets the IsDiscontinued property to either a true or false. Normally this data would be coming from a database, but this mock data illustrates how binding selects the default button chosen when the view renders.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;public ActionResult Radio06()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt; tab-stops: 81.0pt;"&gt;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; Product entity = new Product();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; entity.IsDiscontinued = true;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; return View(entity);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;The second method to add the controller is called when the user clicks on the submit button on the screen. The &amp;lsquo;value&amp;rsquo; attribute of the button selected at the time of the submit will be automatically assigned to the instance of the Product class, named &amp;lsquo;entity&amp;rsquo; in this sample. Within this method I put a Debugger.Break() so you can inspect the properties of the entity variable to see the IsDiscontinued property and verify that it is set to the correct value.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;[HttpPost]&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;public ActionResult Radio06(Product entity)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; System.Diagnostics.Debugger.Break();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; return View(entity);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;That is pretty much all there is to binding to a true/false value using MVC.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;h3&gt;Script for Toggling&lt;o:p&gt;&lt;/o:p&gt;&lt;/h3&gt;
&lt;p class="MsoBodyText"&gt;The jQuery and JavaScript used on this page is the same as what I presented in my last blog post. The only difference is I added code that runs when the page is loaded. This code will select the radio button that is &amp;ldquo;checked&amp;rdquo; and ensure that the proper glyph is rendered on the button. All radio buttons on your page should have the &amp;lsquo;glyphicon-unchecked&amp;rsquo; in the class attribute. This class attribute is changed on the selected radio button by the code that runs when the page is loaded.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@section scripts&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(document).ready(function () {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Detect radio button that is checked and toggle glyph&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("input[type='radio']:checked").prev()&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .removeClass('glyphicon-unchecked')&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .addClass('glyphicon-record');&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;The jQuery code that runs when the page is loaded will first select any radio buttons that are checked. You then need to move the previous element in the DOM which will be the &amp;lt;span&amp;gt; tag with the glyph icon to change. You remove the &amp;lsquo;glyphicon-unchecked and add the class &amp;lsquo;glyphicon-record&amp;rsquo;.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;h2&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;In this blog post you saw how to take our custom radio buttons and bind them to a true/false property on a class. In addition you learned how to take the selected radio button and toggle the glyph icon when the page is loaded.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</description><pubDate>Wed, 12 Nov 2014 17:21:49 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/bind-custom-radio-buttons-to-true-false-property</guid><category>.NET</category><category>jQuery</category><category>Radio Buttons</category><category>Bootstrap</category></item><item><title>Creating Radio Buttons using Bootstrap and MVC</title><link>https://weblogs.asp.net:443/psheriff/creating-radio-buttons-using-bootstrap-and-mvc</link><description>&lt;p&gt;As I previously published, the normal HTML check boxes and radio buttons just do not look good in bootstrap. Yes, bootstrap has a CSS class that will attempt to at least let render a radio button consistently across browsers, but it still is just the default HTML look. In addition, trying to hit a radio button on a mobile phone can sometimes be a little challenging.&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;In an MVC project we are doing for a client, they wanted the radio buttons to look more like buttons. Since we were already using bootstrap for this project we were able to create our own radio buttons using the &amp;ldquo;&lt;b&gt;btn-group&lt;/b&gt;&amp;rdquo; class from bootstrap. Let&amp;rsquo;s walk through how we created these.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Normal Radio Buttons&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;As most of you know, creating normal radio buttons in MVC is easy to do with the Radio Button HTML helper class. The code below is what you write for creating standard HTML radio buttons in MVC:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@using (Html.BeginForm())&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.RadioButton("gender", "Male", &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new { id="IsMale" }) Male&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.RadioButton("gender", "Female", &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new { id = "IsFemale" }) Female&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;NOTE: You must add the new { id=&amp;rdquo;UNIQUE ID&amp;rdquo; } in order to have a unique ID, but the &amp;lsquo;name&amp;rsquo; attribute should be the same for each radio button. In this way you get a group of radio buttons that are mutually exclusive.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Bootstrap Radio Buttons&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Using bootstrap, add a &amp;lt;div&amp;gt; with a class of either &amp;ldquo;radio&amp;rdquo; or &amp;ldquo;radio-inline&amp;rdquo; around your radio buttons. You may optionally also add a &amp;lt;label&amp;gt; element around the radio button in order to use bootstrap&amp;rsquo;s styling of labels. If you use a label you will see a bolder font for the text of the radio button.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@using (Html.BeginForm())&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="radio-inline"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.RadioButton("gender", "Male", true,&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;new { id = "IsMale" }) Male&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="radio-inline"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.RadioButton("gender", "Female", &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;new { id = "IsFemale" }) Female&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Both of the above pieces of code will produce some output that looks like the radio buttons shown in Figure 1.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt; &lt;img width="417" height="379" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/BootstrapRadioButton1.png" /&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Figure 1: Normal HTML Radio Buttons&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Use Button Groups&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;One of the classes that bootstrap supplies is &amp;ldquo;btn-group&amp;rdquo;. This class combined with the attribute data-toggle=&amp;rdquo;buttons&amp;rdquo; gives you the ability to create radio buttons that look like standard buttons but will toggle when pressed. What is nice about radio buttons expressed this way is you can really tell that the label is a part of the radio button. When you click on one of the buttons you will see it change color. A nice side benefit is these buttons are much easier to see and press on a mobile device.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@using (Html.BeginForm())&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="btn-group" data-toggle="buttons"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-primary active"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.RadioButton("gender", "Male", true,&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;new { id = "IsMale" }) Male&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.RadioButton("gender", "Female", &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new { id = "IsFemale" }) Female&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Use the &amp;ldquo;active&amp;rdquo; class on one of the radio buttons in order to make it the &amp;ldquo;selected&amp;rdquo; button (see Figure 2).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt; &lt;img width="477" height="367" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/BootstrapRadioButton2.png" /&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Figure 2: Radio buttons displayed as button groups.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Add Glyphs&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Users are used to seeing a circle with a dot in it or an empty circle next to the label for radio button controls. So, you should add those into your design. Use the built-in glyphs in bootstrap to display a filled in circle or an empty circle. Below is the code to do this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@using (Html.BeginForm())&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="btn-group" data-toggle="buttons"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="pdsa-radiobutton btn btn-primary active"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;span class="glyphicon glyphicon-record"&amp;gt;&amp;lt;/span&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.RadioButton("gender", "Male", true,&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;new { id = "IsMale" }) Male&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="pdsa-radiobutton btn btn-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;span class="glyphicon glyphicon-unchecked"&amp;gt;&amp;lt;/span&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.RadioButton("gender", "Female", &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new { id = "IsFemale" }) Female&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Take a look at the &amp;ldquo;Male&amp;rdquo; radio button. There are two modifications to this radio button. First, you add the &amp;ldquo;active&amp;rdquo; class on the &amp;lt;label&amp;gt; element. This makes it a different color from the other radio button. You also change the glyph in the &amp;lt;span&amp;gt; element from &amp;ldquo;glyphicon-unchecked&amp;rdquo; to &amp;ldquo;glyphicon-record&amp;rdquo; to make it a circle within a circle.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;b&gt;NOTE&lt;/b&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;: Feel free to use whatever icons you want. Font Awesome (&lt;/span&gt;&lt;a href="http://www.fontawesome.io/"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;www.fontawesome.io&lt;/span&gt;&lt;/a&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;) has a lot of different CSS glyphs that you can use instead of the limited ones in bootstrap.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt; &lt;img width="477" height="367" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/BootstrapRadioButton3.png" /&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Figure 3: Add glyphs to make the buttons look more like radio buttons.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Change Glyphs Dynamically using jQuery&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;When the user clicks on a radio button you should toggle the glyph. Luckily when you click on the radio button, bootstrap takes care of toggling the &amp;ldquo;active&amp;rdquo; class on the &amp;lt;label&amp;gt; elements for you. All you need to do is to write some jQuery to toggle the glyphs. Below is the jQuery code you add at the bottom of the .cshtml MVC page to toggle the glyphs.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&amp;lt;script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; $(document).ready(function () {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("#gender &amp;gt; .pdsa-radiobutton").on('click', function () {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pdsaToggleRadioButtons("#gender", $(this));&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; });&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; function pdsaToggleRadioButtons(groupName, current) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Find currently checked radio button in the group&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var chk = $(groupName + &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; " .pdsa-radiobutton .glyphicon-record");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Remove 'record' glyph&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Add 'unchecked' glyph&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(chk).removeClass('glyphicon-record')&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .addClass('glyphicon-unchecked');&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Remove the 'unchecked' glyph, add the 'record' glyph&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(current).find("&amp;gt;:first-child")&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .removeClass('glyphicon-unchecked');&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(current).find("&amp;gt;:first-child")&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .addClass('glyphicon-record');&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;Remember that you may have more than one group of radio buttons, so for this sample I added an &amp;ldquo;id&amp;rdquo; attribute of &amp;ldquo;gender&amp;rdquo; to the &amp;lt;div&amp;gt; element that contains the &amp;ldquo;btn-group&amp;rdquo; class. In the jQuery function that connects to the click event on the radio buttons I pass in the id of the button group I want to affect.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;I created a function called pdsaToggleRadioButtons that accepts two parameters. The first parameter is the id of the group of buttons I want to work within. The second parameter is the control that was just clicked.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;The JavaScript function, pdsaToggleRadioButtons, is fairly straightforward. Locate the current button that has the class &amp;lsquo;glyphicon-record&amp;rsquo; and remove that class. Add the class &amp;lsquo;glyphicon-unchecked&amp;rsquo; to this button so it now appears unchecked to the user. Next, remove the class &amp;lsquo;glyphicon-unchecked&amp;rsquo; from the currently selected button and add the class &amp;lsquo;glyphicon-record&amp;rsquo; so it will appear checked to the user.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;h2&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;In this blog post you learned how to present radio buttons just a little differently. While it is not necessary to do this, I like the way these radio buttons look and feel. With just a little use of built-in bootstrap CSS and jQuery you can get something that looks a little different from the traditional web look.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</description><pubDate>Tue, 14 Oct 2014 12:13:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/creating-radio-buttons-using-bootstrap-and-mvc</guid><category>C#</category><category>.NET</category><category>jQuery</category><category>MVC</category></item><item><title>Bind Check Boxes to a Collection in MVC</title><link>https://weblogs.asp.net:443/psheriff/bind-check-boxes-to-a-collection-in-mvc</link><description>&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;In my last two blog posts I showed you how to use the bootstrap &amp;lsquo;btn-group&amp;rsquo; class to create check boxes that are a little nicer looking and easier to use on a mobile device. In addition I showed you how to bind check boxes to individual properties on an entity class. In this blog post you will learn how to create a set of check boxes from a collection of entity classes. You will also learn how to retrieve which check boxes were checked by the user and update the appropriate entity class in the collection with these values.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt; &lt;img width="538" height="342" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/BootstrapCheckBox3-01.png" /&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p class="ScrShotWide"&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt; &lt;v:stroke joinstyle="miter"&gt; &lt;v:formulas&gt; &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt; &lt;v:f eqn="sum @0 1 0"&gt; &lt;v:f eqn="sum 0 0 @1"&gt; &lt;v:f eqn="prod @2 1 2"&gt; &lt;v:f eqn="prod @3 21600 pixelWidth"&gt; &lt;v:f eqn="prod @3 21600 pixelHeight"&gt; &lt;v:f eqn="sum @0 0 1"&gt; &lt;v:f eqn="prod @6 1 2"&gt; &lt;v:f eqn="prod @7 21600 pixelWidth"&gt; &lt;v:f eqn="sum @8 21600 0"&gt; &lt;v:f eqn="prod @7 21600 pixelHeight"&gt; &lt;v:f eqn="sum @10 21600 0"&gt; &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt; &lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt; &lt;o:lock v:ext="edit" aspectratio="t"&gt; &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;v:shape id="Picture_x0020_1" o:spid="_x0000_i1025" type="#_x0000_t75" style="width: 404.25pt; height: 256.5pt; visibility: visible; mso-wrap-style: square;"&gt; &lt;v:imagedata src="file:///D:\Temp\msohtmlclip1\01\clip_image001.png" o:title=""&gt; &lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="ScrShotWide"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Figure 1: Create checkboxes from a collection of entity classes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Music Genre Class&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Create a class for each music genre you wish to display in the check boxes shown in Figure 1. For each genre of music you need a unique id, the string to display and a boolean value for whether or not it was selected. The MusiGener class, shown below contains the appropriate properties along with a constructor to create a MusicGenre instance from values passed to the constructor.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;public class MusicGenre&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public int GenreId { get; set; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public string Genre {get;set;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public bool IsSelected { get; set; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Constructor to create new MusicGenre object&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;span lang="FR-CA"&gt;public MusicGenre(int id, string genre)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;span lang="FR-CA"&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;span lang="FR-CA"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; GenreId = id;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;span lang="FR-CA"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genre = genre;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;span lang="FR-CA"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;IsSelected = false;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Create View Model Class&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Using a View Model class from your controller is an excellent way to get reusability across different UI technologies. A view model is usable from Web Forms, WPF, Windows Phone and even Windows Forms applications. You can also unit test view model classes easily. Create a view model class that builds a collection of musical genres from a database table (or any other data store). Create an instance of this view model in your controller and use this instance as the @model in your .cshtml file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;public class MusicGenreViewModel&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public MusicGenreViewModel()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; LoadGenresMock();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public List&amp;lt;MusicGenre&amp;gt; Genres { get; set; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public void LoadGenresMock()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Create mock list of data&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Normally you would load this data from a database&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genres = new List&amp;lt;MusicGenre&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genres.Add(new MusicGenre(1, "Jazz"));&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genres.Add(new MusicGenre(2, "Country"));&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genres.Add(new MusicGenre(3, "Rock"));&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genres.Add(new MusicGenre(4, "Blues"));&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Genres.Add(new MusicGenre(5, "Alternative Rock"));&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;In the view model class, named MusicGenreViewModel, I created a method called LoadGenresMock(). Normally you would call your data layer to get this list of musical genres from a database table, but for this example, I just needed some data to build my list of check boxes, so I hard-coded the values.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Bind to Collection of Musical Genres&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Once you have your collection of musical genres loaded into your view model, create an instance of the view model class in your controller. You can optionally set the IsSelected property of any specific genres to true in order to have those check boxes &amp;ldquo;checked&amp;rdquo; when the screen first displays. Pass the view model to your View, named CollectionTest, as shown in the code below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;public ActionResult CollectionTest()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; MusicGenreViewModel vm = new MusicGenreViewModel();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; vm.Genres.Find(g =&amp;gt; g.Genre == "Jazz").IsSelected = true;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; vm.Genres.Find(g =&amp;gt; g.Genre == "Rock").IsSelected = true;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; return View(vm);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;View for Collection of Check Boxes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Create a new view in an MVC project, named CollectionTest, and add the @model to use the view model class. To build the list of check boxes you will need to loop through the Genres collection. Each time through the loop is where you need to create each check box from the MusicGenre class. However, since you can&amp;rsquo;t have two @model statements in a view, create a partial view that you can pass each instance of the MusicGenre class to. The code for the CollectionTest view is shown below:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@model BootstrapCheckBoxes3.MusicGenreViewModel&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;@using (Html.BeginForm())&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="well"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;h3&amp;gt;Checkboxes Built from a Collection&amp;lt;/h3&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="row"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="col-md-8"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="btn-group" data-toggle="buttons"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @foreach (var item in @Model.Genres)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Html.RenderPartial("_CollectionTestGenre", item);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="row"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="col-md-12"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;button class="btn btn-success"&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; type="submit"&amp;gt;Submit&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/button&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h3&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Partial View&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;The partial view, called _CollectionTestGenre, is where you create each check box. Notice that you have a @model in this partial view that is the instance passed in of the MusicGenre class from the main view. In this partial view is where you use the CheckBoxFor() helper method to create the check box. Notice that you will set the &amp;lsquo;value&amp;rsquo; attribute of each check box to the GenreId. You will use this value when the data is posted back.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@model BootstrapCheckBoxes2.MusicGenre&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;lt;label class="pdsa-checkbox-group btn btn-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;span class="glyphicon glyphicon-unchecked"&amp;gt;&amp;lt;/span&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&lt;b&gt;@Html.CheckBoxFor(m =&amp;gt; m.IsSelected, &lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/b&gt;&lt;b&gt;&lt;span lang="FR-CA"&gt;new { value = @Model.GenreId })&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;span lang="FR-CA"&gt;&amp;nbsp; @Html.LabelFor(x =&amp;gt; x.Genre, Model.Genre)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Posting Collection Back to Controller&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Once you have checked and unchecked any of the check boxes, click on the Submit button to post back the form data. As mentioned earlier the &amp;lsquo;value&amp;rsquo; attribute of each check box is set to the GenreId. When you check a check box on the form, the value attribute is what is posted back for that check box. All unchecked check boxes will have the value &amp;lsquo;false&amp;rsquo; posted back.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;The name of each check box is set to IsSelected, so if you call Request.Form[&amp;ldquo;IsSelected&amp;rdquo;] you will get back a comma-delimited list of all check boxes that have been selected and not selected. If you check 3 of the check boxes, you get back a string that looks like the following:&lt;/span&gt; "1,false,2,false,3,false,false,false". All you have to do is convert this comma-delimited list to an array and find all the numeric values. Take each numeric value and place into an integer array. From this integer array set the appropriate Genre&amp;rsquo;s IsSelected property to true if the integer value is the same as the GenreId.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;As you will most likely be using different check boxes on different web pages, create a generic method to perform this conversion from a string to an integer array. I created a WebCommon class and created a method called RequestSelectionToList(). This method, shown below, uses the Split() method of the string class to separate each value from the comma-delimited list and create an array. The array is then converted to a generic list of string values using the ToList() method. It then loops through this list of string values looking for integer values. For each integer value it finds, it adds that value to a generic integer list.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;public class WebCommon&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;public static List&amp;lt;int&amp;gt; RequestSelectionToList(&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; string values)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;List&amp;lt;int&amp;gt; ret = new List&amp;lt;int&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;List&amp;lt;string&amp;gt; selected = values.Split(',').ToList();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;int value = 0;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;// Loop through selected items looking for integer values&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;foreach (string item in selected)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if (int.TryParse(item, out value))&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ret.Add(value);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;return ret;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Once you have this class created and this method to extract the list of integer values from the Request.Form[&amp;ldquo;IsSelected&amp;rdquo;], you can now use it in the controller. Create a method in your controller to respond to the HttpPost. Write the following code in your controller to set the appropriate IsSelected properties in the Genres collection.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;[HttpPost]&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;public ActionResult CollectionTest(MusicGenreViewModel vm)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; List&amp;lt;int&amp;gt; selected = WebCommon.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RequestSelectionToList(Request.Form["IsSelected"]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; // Loop through selected items looking for integer values&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; foreach (int item in selected)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Set the IsSelected property on the appropriate GenreId&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vm.Genres.Find(g =&amp;gt; g.GenreId == item).IsSelected = true;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; return View(vm);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Working with check boxes in a collection takes a little more work than just setting individual boolean values in a simple entity class. If you set the &amp;lsquo;value&amp;rsquo; attribute to the unique id for each of your check boxes, you will be able to retrieve the unique id from the Request.Form collection. From this you can set your appropriate boolean property to true for each check box selected by your user.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</description><pubDate>Sun, 21 Sep 2014 14:48:31 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/bind-check-boxes-to-a-collection-in-mvc</guid><category>MVC</category><category>ASP.NET</category><category>Check Boxes</category><category>C#</category></item><item><title>Bind Check Boxes in MVC</title><link>https://weblogs.asp.net:443/psheriff/bind-check-boxes-in-mvc</link><description>&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;After the last post on how to create check boxes that use the bootstrap &amp;ldquo;btn-group&amp;rdquo; to modify the look and feel of check boxes, I thought it would be good to show how to bind these check boxes using MVC. After all, you will most likely need to display check boxes based on data from a table.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt; &lt;img width="495" height="392" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/BootstrapCheckBox2-01.png" /&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt; &lt;v:stroke joinstyle="miter"&gt; &lt;v:formulas&gt; &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt; &lt;v:f eqn="sum @0 1 0"&gt; &lt;v:f eqn="sum 0 0 @1"&gt; &lt;v:f eqn="prod @2 1 2"&gt; &lt;v:f eqn="prod @3 21600 pixelWidth"&gt; &lt;v:f eqn="prod @3 21600 pixelHeight"&gt; &lt;v:f eqn="sum @0 0 1"&gt; &lt;v:f eqn="prod @6 1 2"&gt; &lt;v:f eqn="prod @7 21600 pixelWidth"&gt; &lt;v:f eqn="sum @8 21600 0"&gt; &lt;v:f eqn="prod @7 21600 pixelHeight"&gt; &lt;v:f eqn="sum @10 21600 0"&gt; &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt; &lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt; &lt;o:lock v:ext="edit" aspectratio="t"&gt; &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;v:shape id="Picture_x0020_1" o:spid="_x0000_i1025" type="#_x0000_t75" style="width: 371.25pt; height: 294pt; visibility: visible; mso-wrap-style: square;"&gt; &lt;v:imagedata src="file:///D:\Temp\msohtmlclip1\01\clip_image001.png" o:title=""&gt; &lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Figure 1: Check boxes should be bound to an entity class&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Musical Tastes Entity Class&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;The first step is to have an entity (or model) class that contains the appropriate properties to bind to these check boxes. Below is a class I called MusicalTastes that simply has three Boolean properties that correspond to the three check boxes on the screen shown in Figure 1.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;public class MusicalTastes&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public bool IsJazz { get; set; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public bool IsCountry { get; set; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; public bool IsRock { get; set; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;View for Musical Tastes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Create a .cshtml view and add a &lt;b&gt;@model&lt;/b&gt; statement at the top of the page to bind to an instance of this MusicalTastes class. Use the @Html.CheckBoxFor() helper to bind to each property instead of the @Html.CheckBox() helper as you did in the last blog entry.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@model BootstrapCheckBoxes2.MusicalTastes&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;@using (Html.BeginForm())&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="btn-group" data-toggle="buttons"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;span class="glyphicon glyphicon-unchecked"&amp;gt;&amp;lt;/span&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.CheckBoxFor(m =&amp;gt; m.IsJazz) Jazz&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;span class="glyphicon glyphicon-unchecked"&amp;gt;&amp;lt;/span&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.CheckBoxFor(m =&amp;gt; m.IsCountry) Country&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;span class="glyphicon glyphicon-unchecked"&amp;gt;&amp;lt;/span&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.CheckBoxFor(m =&amp;gt; m.IsRock) Rock&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;button type="submit" &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class="btn btn-success"&amp;gt;Submit&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/button&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Notice that the expressions you pass to the first parameter of this CheckBoxFor helper have the names of each of the properties in the MusicalTastes class. This is what binds this check box to each of the properties.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Binding to Musical Tastes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;In the controller for this .cshtml page create an instance of the MusicalTastes class and set one or more of the properties to true in order to see the check box checked when the page displays.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;public ActionResult BindingTest()&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; MusicalTastes entity = new MusicalTastes();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; entity.IsCountry = true;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; return View(entity);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;jQuery for Musical Tastes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;In order to get the correct display for any property set to true you need to write some JavaScript/jQuery to toggle the glyphs. Below is the code you would add to the end of the $(document).ready(). Keep the same code you had in the previous blog post to toggle the check boxes when you click on each one, but add code that will run when the page loads as shown in the bold code below:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@section scripts&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(document).ready(function () {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Connect to 'change' event in order to toggle glyphs&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("[type='checkbox']").change(function () {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($(this).prop('checked')) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(this).prev().addClass('glyphicon-ok-circle');&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(this).prev().removeClass('glyphicon-unchecked');&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(this).prev().removeClass('glyphicon-ok-circle');&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(this).prev().addClass('glyphicon-unchecked');&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Detect checkboxes that are checked and toggle glyphs&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var checked = $("input:checked");&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; checked.prev().removeClass('glyphicon-unchecked');&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; checked.prev().addClass('glyphicon-ok-circle');&lt;o:p&gt;&lt;/o:p&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;This code selects all check boxes checked via the automatic data binding. It then removes the unchecked glyph and adds the ok-circle glyph to all those check boxes.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Posting Back Musical Tastes Selected&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;There is nothing to do to get the selected check boxes to post back to your entity class. Simply create a method in your controller with the [HttpPost] attribute. Pass in the entity class to this method and MVC will take care of matching the names of the check boxes to the appropriate properties in your entity class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;[HttpPost]&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;public ActionResult BindingTest(MusicalTastes entity)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; System.Diagnostics.Debugger.Break();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; return View(entity);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;I added the Debugger.Break() statement so I can hover over the &amp;lsquo;entity&amp;rsquo; variable and verify that the check boxes checked have been updated in the instance of the MusicalTastes class passed in.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Binding an entity class with boolean properties to a set of check boxes on a .cshtml is very easy to do. Simply create your class and use the @Html.CheckBoxFor() helper class to bind your check boxes to the appropriate properties. Add a little bit of client-side JavaScript/jQuery to toggle the glyphs and you have a very nice looking interface for your check box controls.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</description><pubDate>Fri, 19 Sep 2014 14:34:56 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/bind-check-boxes-in-mvc</guid><category>MVC</category><category>ASP.NET</category><category>Check Box</category><category>Bootstrap</category></item><item><title>Creating Checkboxes using Bootstrap and MVC</title><link>https://weblogs.asp.net:443/psheriff/creating-checkboxes-using-bootstrap-and-mvc</link><description>&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;The normal HTML check box just does not look good. Yes, bootstrap has a CSS class that will attempt to at least let it render consistently across browsers, but it still is just the default HTML look. In addition, trying to hit a check box on a mobile phone can sometimes be a little challenging.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;In an MVC project we are doing for a client, they wanted the check boxes to look more like buttons. Since we were already using bootstrap for this project we were able to create our own check boxes using the &amp;ldquo;&lt;b&gt;btn-group&lt;/b&gt;&amp;rdquo; class from bootstrap. Let&amp;rsquo;s walk through how we created these.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Normal Check Boxes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;As most of you know, creating normal check boxes in MVC is easy to do with the CheckBox HTML helper class. The code below is what you write for creating standard HTML check boxes in MVC:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@using (Html.BeginForm())&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.CheckBox("IsJazz") Jazz&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.CheckBox("IsCountry") Country&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.CheckBox("IsRock") Rock&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Bootstrap Check Boxes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;With bootstrap you add a &amp;lt;div&amp;gt; with a class of either &amp;ldquo;checkbox&amp;rdquo; or &amp;ldquo;checkbox-inline&amp;rdquo; around your check boxes. You also add a &amp;lt;label&amp;gt; element around the check boxes in order to use bootstrap&amp;rsquo;s styling of labels. Normally this gives you a bolder font for the actual text of the check box.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@using (Html.BeginForm())&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="checkbox-inline"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.CheckBox("IsJazz") Jazz&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="checkbox-inline"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.CheckBox("IsCountry") Country&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="checkbox-inline"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.CheckBox("IsRock") Rock&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Both of the above pieces of code will produce some output that looks like the check boxes shown in Figure 1.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt; &lt;img width="389" height="391" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/BootstrapCheckBox01.png" /&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"&gt; &lt;v:stroke joinstyle="miter"&gt; &lt;v:formulas&gt; &lt;v:f eqn="if lineDrawn pixelLineWidth 0"&gt; &lt;v:f eqn="sum @0 1 0"&gt; &lt;v:f eqn="sum 0 0 @1"&gt; &lt;v:f eqn="prod @2 1 2"&gt; &lt;v:f eqn="prod @3 21600 pixelWidth"&gt; &lt;v:f eqn="prod @3 21600 pixelHeight"&gt; &lt;v:f eqn="sum @0 0 1"&gt; &lt;v:f eqn="prod @6 1 2"&gt; &lt;v:f eqn="prod @7 21600 pixelWidth"&gt; &lt;v:f eqn="sum @8 21600 0"&gt; &lt;v:f eqn="prod @7 21600 pixelHeight"&gt; &lt;v:f eqn="sum @10 21600 0"&gt; &lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:f&gt;&lt;/v:formulas&gt; &lt;v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"&gt; &lt;o:lock v:ext="edit" aspectratio="t"&gt; &lt;/o:lock&gt;&lt;/v:path&gt;&lt;/v:stroke&gt;&lt;/v:shapetype&gt;&lt;v:shape id="Picture_x0020_1" o:spid="_x0000_i1027" type="#_x0000_t75" style="width: 291.75pt; height: 293.25pt; visibility: visible; mso-wrap-style: square;"&gt; &lt;v:imagedata src="file:///D:\Temp\msohtmlclip1\01\clip_image001.png" o:title=""&gt; &lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Figure 1: Normal HTML Check boxes&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Use Button Groups&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;One of the classes that bootstrap supplies is &amp;ldquo;btn-group&amp;rdquo;. This class combined with the data-toggle=&amp;rdquo;buttons&amp;rdquo; gives you the ability to create check boxes that look like standard buttons but will toggle when pressed. What is nice about check boxes expressed this way is you can really tell that the label is a part of the check box. When you click on one of the buttons you will see it change color. In addition, these buttons are much easier to press on a mobile device.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@using (Html.BeginForm())&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="btn-group" data-toggle="buttons"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.CheckBox("IsJazz") Jazz&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-primary active"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.CheckBox("IsCountry") Country&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.CheckBox("IsRock") Rock&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Note the use of the &amp;ldquo;active&amp;rdquo; class on the Country check box. This is what makes this one selected when you display the screen (see Figure 2).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt; &lt;img width="441" height="356" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/BootstrapCheckBox02.png" /&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p class="ScrShotMedium"&gt;&lt;v:shape id="Picture_x0020_2" o:spid="_x0000_i1026" type="#_x0000_t75" style="width: 330.75pt; height: 267pt; visibility: visible; mso-wrap-style: square;"&gt; &lt;v:imagedata src="file:///D:\Temp\msohtmlclip1\01\clip_image002.png" o:title=""&gt; &lt;/v:imagedata&gt;&lt;/v:shape&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Figure 2: Check boxes displayed as button groups.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Add Glyphs&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Users are used to seeing a check mark or an empty box next to the label for check box controls. So, you should add those into your design. Use the built-in glyphs in bootstrap to display a check or an empty box. Below is the code to do this:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@using (Html.BeginForm())&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;div class="form-group"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div class="btn-group" data-toggle="buttons"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;span class="glyphicon glyphicon-unchecked"&amp;gt;&amp;lt;/span&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;@Html.CheckBox("IsJazz", true) Jazz&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-primary active"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;span class="glyphicon glyphicon-ok-circle"&amp;gt;&amp;lt;/span&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.CheckBox("IsCountry") Country&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;label class="btn btn-primary"&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;span class="glyphicon glyphicon-unchecked"&amp;gt;&amp;lt;/span&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @Html.CheckBox("IsRock", true) Rock&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/label&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/div&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Take a look at the Country check box. There are two modifications to this check box. First, you add the &amp;ldquo;active&amp;rdquo; class on the &amp;lt;label&amp;gt; element. This makes it a different color from the other two check boxes. You also change the glyph in the &amp;lt;span&amp;gt; element from &amp;ldquo;glyphicon-unchecked&amp;rdquo; to &amp;ldquo;glyphicon-ok-circle&amp;rdquo; to give it a check mark within a circle.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Feel free to use whatever icons you want. Font Awesome (&lt;a href="http://www.fontawesome.io/"&gt;www.fontawesome.io&lt;/a&gt;) has a lot of different CSS glyphs that you can use instead of the limited ones in bootstrap.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt; &lt;img width="444" height="327" alt="" src="https://aspblogs.blob.core.windows.net:443/media/psheriff/ImagesForBlog/BootstrapCheckBox03.png" /&gt; &lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;Figure 3: Add glyphs to make the buttons look more like check boxes.&lt;/p&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Change Glyphs Dynamically using jQuery&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;When the user clicks on a check box you want to toggle the glyph. Luckily when you click on the check box, bootstrap takes care of toggling the &amp;ldquo;active&amp;rdquo; class on the &amp;lt;label&amp;gt; elements for you. All you need to do is to write some jQuery to toggle the glyphs. Below is the jQuery code you add at the bottom of the .cshtml MVC page to toggle the glyphs.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;@section scripts&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(document).ready(function () {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Connect to 'change' event in order to toggle glyphs&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $("[type='checkbox']").change(function () {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if ($(this).prop('checked')) {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(this).prev().addClass('glyphicon-ok-circle');&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(this).prev().removeClass('glyphicon-unchecked');&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else {&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(this).prev().removeClass('glyphicon-ok-circle');&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(this).prev().addClass('glyphicon-unchecked');&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; &amp;lt;/script&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;This jQuery is fairly simple to understand. When the user changes the check box you determine if the check box is checked or unchecked. Based on this setting you either add or remove the appropriate classes from the &amp;lt;span&amp;gt; element that is just prior to the check box control.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;h2&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/h2&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;In this blog post you learned how to present check boxes just a little differently. While it is not necessary to do this, I like the way these check boxes look and feel. With just a little use of built-in bootstrap CSS and jQuery you can get something that looks a little different from the traditional web look.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;</description><pubDate>Tue, 16 Sep 2014 18:16:34 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/creating-checkboxes-using-bootstrap-and-mvc</guid><category>Bootstrap</category><category>MVC</category><category>CSS</category><category>CheckBox</category></item><item><title>Using Friendly URLs in Web Forms</title><link>https://weblogs.asp.net:443/psheriff/using-friendly-urls-in-web-forms</link><description>&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Friendly URls&lt;/span&gt; help you eliminate query string parameters and file extensions from the URL line. So, instead of&amp;hellip;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;www.url.com/Products.aspx&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;www.url.com/Products.aspx?ProductId=3&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;You use simple friendly URLs instead as shown below:&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;www.url.com/Products&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;www.url.com/Products/3&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;There are many benefits of using friendly URLs in your web applications.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText" style="margin-left: 1.25in; text-indent: -.25in; mso-list: l0 level1 lfo1;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"&gt;&amp;middot;&lt;span style="font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;Cleaner query string&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText" style="margin-left: 1.25in; text-indent: -.25in; mso-list: l0 level1 lfo1;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; mso-fareast-font-family: Symbol; mso-bidi-font-family: Symbol;"&gt;&amp;middot;&lt;span style="font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;User does not know the actual page name&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText" style="margin-left: 1.25in; text-indent: -.25in; mso-list: l0 level1 lfo1;"&gt;&lt;!--[if !supportLists]--&gt;&lt;span style="font-family: Symbol; background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&amp;middot;&lt;span style="font-size: 7pt; line-height: normal; font-family: 'Times New Roman';"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;!--[endif]--&gt;Easier for users to use&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;Friendly URLs are available in Web Forms and MVC. I see a lot of examples of using friendly URLs using MVC, but very few using Web Forms. So, I thought I would discuss how to use them in Web Forms. Actually, the process is almost identical.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;First you need to download the &lt;b&gt;Microsoft.Asp.Net.FriendlyUrls.Core.dll&lt;/b&gt; if you don&amp;rsquo;t already have it in your project. If you have an older ASP.NET application you probably don&amp;rsquo;t have it. If you are starting a new project in Visual Studio 2013, and choose the Web Forms template, this DLL is already present.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;If you want to use friendly URLs in an older project, select &lt;b&gt;Tools&lt;/b&gt; | &lt;b&gt;Nuget Package Manager&lt;/b&gt; | &lt;b&gt;Manage NuGet Packages for Solution...&lt;/b&gt; from the Visual Studio menu. Search online for Microsoft.AspNet.FriendlyUrls and install the Microsoft.AspNet.FriendlyUrls.Core. You don&amp;rsquo;t need any of the other DLLs in the NuGet packages list, just the &amp;ldquo;Core&amp;rdquo; DLL.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;If you have an App_Start folder, check and see if you have a class called RouteConfig.cs in there. If so, then you already have what you need. If you don&amp;rsquo;t, then add a class called &lt;b&gt;RouteConfig&lt;/b&gt; to your project.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;Add the following &lt;b&gt;&lt;i&gt;using&lt;/i&gt;&lt;/b&gt; statements at the top of this new class file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;using System.Web.Routing;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;using Microsoft.AspNet.FriendlyUrls;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;Either add the following method, or modify it to look like the following. This assumes you have 3 pages in your project; Default.aspx, Customers.aspx, and Products.aspx. Feel free to substitute your page names as appropriate.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;public static void RegisterRoutes(RouteCollection routes)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; routes.EnableFriendlyUrls();&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; routes.MapPageRoute("", "Default", "~/Default.aspx");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; routes.MapPageRoute("", "Customers", "~/Customers.aspx");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; routes.MapPageRoute("GetCustomer",&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;"GetCustomer/{CustomerId}",&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "~/Customers.aspx");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; routes.MapPageRoute("", "Products", "~/Products.aspx");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; routes.MapPageRoute("GetProduct", "GetProduct/{ProductId}",&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "~/Products.aspx");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;In the above page routes you have some parameter placeholders denoted by the curly braces {}. These are what you use to pass any parameters to and the names you use to retrieve those values.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="MsoBodyText"&gt;The next step is to open your Global.asax and either add, or check to see, if you have the following &lt;b&gt;&lt;i&gt;using&lt;/i&gt;&lt;/b&gt; statement at the top of the file.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 2.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeAlone" style="margin-top: .25in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;using System.Web.Routing;&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;In the Application_Start() event you now need to call the RegisterRoutes method you created in the last step. The &lt;b&gt;RouteTable.Routes&lt;/b&gt; object, created by the ASP.NET engine, is what you add to in your RegisterRoutes method.&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 2.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeAlone" style="margin-top: .25in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;RouteConfig.RegisterRoutes(RouteTable.Routes);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;You can now run your ASP.NET application type in any of the following:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&lt;span class="MsoHyperlink"&gt;http://localhost:xxxx/Products&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;span class="MsoHyperlink"&gt;http://localhost:xxxx/GetProduct/22&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&lt;span class="MsoHyperlink"&gt;http://localhost:xxxx/Customers&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&lt;span class="MsoHyperlink"&gt;http://localhost:xxxx/GetCustomer/ABC&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;From any &amp;lt;a&amp;gt; tag on your web pages you can now use the following syntax:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&amp;lt;a href=&lt;/span&gt;"Products"&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&amp;gt;Get All Products&amp;lt;/a&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&amp;lt;a href=&lt;/span&gt;"GetProduct/22"&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&amp;gt;Get Product #22&amp;lt;/a&amp;gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Notice that you don&amp;rsquo;t need the &amp;ldquo;.aspx&amp;rdquo; extension. If you are using the Response object to redirect from code behind, may also use the same shorthand for any route that does not have a parameter.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;Response.Redirect("Products");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;Response.Redirect("Customers");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h3&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Passing Parameters using the Response Object&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;If you are going to pass either a customer id or a product id to your pages, and you want to use the Response object, you need to setup things a little differently. Remember you created the following map page route in the RouteConfig class.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;routes.MapPageRoute("GetProduct", "GetProduct/{ProductId}",&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "~/Samples/ProductView.aspx");&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;To redirect to this page, you use the RedirectToRoute method of the Response object.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;Response.RedirectToRoute("GetProduct", &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;&amp;nbsp;new {ProductId = 33});&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;The first parameter you pass to the RedirectToRoute method must match the first parameter in the MapPageRoute. The second parameter is an object with the name in the braces {ProductId} set to the value you wish to pass (in the above case 33).&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Retrieve the Passed Parameters&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;To retrieve the value passed you use the Page.RouteData.Values property. Pass in the name of the parameter you are looking for, in this case &amp;ldquo;ProductId&amp;rdquo; and it will return either a null if not found, or the value. You typically retrieve these values from the Page_Load event procedure.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;
&lt;div style="mso-element: para-border-div; border: double silver 1.5pt; padding: 4.0pt 4.0pt 4.0pt 4.0pt; margin-left: 1.0in; margin-right: .3in;"&gt;
&lt;p class="SourceCodeTop" style="margin-top: .25in; margin-right: 0in; margin-bottom: .0001pt; margin-left: 0in;"&gt;if (Page.RouteData.Values["ProductId"] != null)&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp; int ProductId = &lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCode" style="margin: 0in; margin-bottom: .0001pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Convert.ToInt32(Page.RouteData.Values["ProductId"]);&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;p class="SourceCodeBottom" style="margin-top: 0in; margin-right: 0in; margin-bottom: 12.0pt; margin-left: 0in;"&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;h2&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Summary&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;&lt;span style="background-image: initial; background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial; background-position: initial; background-repeat: initial;"&gt;Using friendly URLs is quite easy to accomplish in either Web Forms or MVC. You can download the friendly URLs &amp;ldquo;Core&amp;rdquo; DLL from NuGet to add to any project. Then with just a few lines of code you can start calling your pages in a very user-friendly manner.&lt;/span&gt;&lt;/p&gt;</description><pubDate>Tue, 16 Sep 2014 17:28:09 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/using-friendly-urls-in-web-forms</guid><category>Web Forms</category><category>ASP.NET</category><category>C#</category><category>Friendly URLs</category></item><item><title>New Course on Pluralsight (Mobile Web Forms)</title><link>https://weblogs.asp.net:443/psheriff/new-course-on-pluralsight-mobile-web-forms</link><description>&lt;p&gt;Hello Everyone,&lt;/p&gt;
&lt;p&gt;I am pleased to announce that I have a new course on Pluralsight!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Building Mobile Web Sites Using Web Forms, Bootstrap, and HTML5&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Most of us build typical business web sites using ASP.NET Web Forms. We are now being asked to build these as mobile-aware web sites. Using Bootstrap is a great place to start and Web Forms can do all of this - without having to learn MVC. This course will teach you how to build business applications using Web Forms, Bootstrap, HMTL5 and CSS3. You will be shown how to create standard business pages such as a Member Log In, Forgot Password, Member Sign Up, About, Contact Us, Address, Member Profile, Credit Card, and many others. You will also learn how to create navigation for your business application.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://beta.pluralsight.com/courses/building-mobile-web-sites-web-forms-bootstrap-html5"&gt;http://beta.pluralsight.com/courses/building-mobile-web-sites-web-forms-bootstrap-html5&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Check it out!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;While you are there, be sure to check out all of my other courses as well.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;How to Start and Run A Consulting Business&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Have you ever wanted to break out of the corporate life and be your own boss? Many people have this dream. In this course you will learn what it takes to start and be successful in your own consulting business. Throughout this course you will learn how to determine what your company should look like, how to manage your money wisely, how to get and keep clients, how best to survive the ups and downs of the economy and how to create an exit strategy. Your instructor has been running his own successful business for over 22 years and shares his valuable insight so you too can be a success!&lt;/p&gt;
&lt;p&gt;&lt;a href="http://pluralsight.com/training/Courses/TableOfContents/start-run-consulting-business"&gt;http://pluralsight.com/training/Courses/TableOfContents/start-run-consulting-business&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Many Approaches to XML Processing in .NET Applications&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Did you know that you can use XML instead of a SQL database for applications? Did you know there is LINQ to XML that allows you to process XML documents quickly and efficiently? If the answer is no to either of these two questions, then you need to watch this course. XML files are very common in today's programming world. You will most likely need to read files, write files and query XML within your applications. .NET provides a rich set of XML processing classes that you can use to perform all these functions. C# allows you to easily create, read and query XML files using XPath, LINQ to XML and other methods. In this course you will learn to read and write XML files using the various .NET classes. You will see some real-world uses of XML files in applications.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://pluralsight.com/training/Courses/TableOfContents/xml-processing-approaches-dotnet-applications"&gt;http://pluralsight.com/training/Courses/TableOfContents/xml-processing-approaches-dotnet-applications&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;WPF for the Business Programmer&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There are so many cool things you can do with WPF that would be impossible or very difficult with Windows Forms. In this course you will see some creative ways to use the WPF List Box. Some screens that you can use right away in your business applications will be presented. You will learn some unique ways to put together user controls to create unique shapes. Finally you will create a shell application to make your WPF application look like Windows 8. This course goes way beyond the basics of WPF to give you some unique insights on how to create business applications.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://pluralsight.com/training/Courses/TableOfContents/wpf-business-programmer"&gt;http://pluralsight.com/training/Courses/TableOfContents/wpf-business-programmer&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;WPF for the Visual Basic Programmer - Part 1&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Visual Basic Programmers are still in demand. Upgrade your skills by learning XAML and WPF. This course is specifically designed for the Visual Basic programmer and will get you up to speed quickly with WPF. In Part 1 you will learn the correct way to design WPF windows, how to use styles and all the most commonly used controls for business applications. You will gain a good knowledge of data binding and how to use the various list controls in WPF.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://pluralsight.com/training/Courses/TableOfContents/wpf-vb-programmer-pt1"&gt;http://pluralsight.com/training/Courses/TableOfContents/wpf-vb-programmer-pt1&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;WPF for the Visual Basic Programmer - Part 2&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Visual Basic Programmers are still in demand. Upgrade your skills by learning XAML and WPF. This course is specifically designed for the Visual Basic programmer and will get you up to speed quickly with WPF. In Part 2 you will learn the correct way to design WPF windows, how to use styles and all the most commonly used controls for business applications. You will gain a good knowledge of data binding and how to use the various list controls in WPF.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://pluralsight.com/training/Courses/TableOfContents/wpf-vb-programmer-pt2"&gt;http://pluralsight.com/training/Courses/TableOfContents/wpf-vb-programmer-pt2&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;br /&gt;Paul&lt;/p&gt;</description><pubDate>Fri, 29 Aug 2014 22:12:43 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/psheriff/new-course-on-pluralsight-mobile-web-forms</guid><category>.NET</category><category>Bootstrap</category><category>Mobile</category><category>Web Forms</category></item></channel></rss>