<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Jaime del Palacio </title><link>https://weblogs.asp.net:443/jaimedelpalacio/</link><description>On software development</description><item><title>Testing code that uses Dapper 1.10</title><link>https://weblogs.asp.net:443/jaimedelpalacio/testing-code-that-uses-dapper-1-10</link><description>&lt;p&gt;&lt;a href="http://code.google.com/p/dapper-dot-net/" target="_blank"&gt;Dapper&lt;/a&gt; is a wonderful and simple .NET library to execute SQL statements against your database, what's now called a Micro-ORM. I have a project that uses Dapper for some specific queries and (as you always should) have it cover by tests. &lt;/p&gt;  &lt;p&gt;This was my test code (using Moq):&lt;/p&gt;  &lt;p&gt;&lt;span class="lnum"&gt;&amp;#160;&amp;#160; 1:&amp;#160; &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SomeTest() &lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    DataTable dt = SetupDummyClassDT();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    _command.Setup(a =&amp;gt; a.ExecuteReader()).Returns(dt.CreateDataReader());&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    &lt;span class="kwrd"&gt;string&lt;/span&gt; calledCommand = &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;    _command.SetupSet(cmd =&amp;gt; cmd.CommandText)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;        .Callback(cmd =&amp;gt; calledCommand = cmd)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        .Verifiable();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    _target.Single&amp;lt;DummyClass&amp;gt;(1);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;    Assert.AreEqual(&lt;span class="str"&gt;&amp;quot;select * from dummyclass where Id = @Id&amp;quot;&lt;/span&gt;, calledCommand);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;_command is a Moq object and _target is my class under test (a repository class that takes care of creating the SQL command for the class)… This was all ok until this morning that I upgraded to Dapper 1.10 and some of my tests broke. Why!!&lt;/p&gt;

&lt;p&gt;The problem, turns out, was that internally dapper needs to add parameters to the IDbCommand.Parameters collection and this was null in my IDbCommand stub (_command), so stubbing the Parameters collection takes care of that; but Dapper creates the parameters calling CreateParameter on the IDbCommand, so we need to stub that too to return a new IDbDataParameter, and problem solve. My test ended up like this:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SomeTest() {
    &lt;span class="rem"&gt;// setup&lt;/span&gt;
    DataTable dt = SetupDummyClassDT();
    _command.Setup(a =&amp;gt; a.ExecuteReader()).Returns(dt.CreateDataReader());

    &lt;span class="rem"&gt;// we need to setup the parameters list and the CreateParameter method&lt;/span&gt;
    &lt;span class="rem"&gt;// so dapper can do its magic without crashing&lt;/span&gt;
    Mock&amp;lt;IDataParameterCollection&amp;gt; paramsList = &lt;span class="kwrd"&gt;new&lt;/span&gt; Mock&amp;lt;IDataParameterCollection&amp;gt;();
    _command.SetupGet(a =&amp;gt; a.Parameters)
        .Returns(paramsList.Object);
    _command.Setup(a =&amp;gt; a.CreateParameter())
        .Returns(&lt;span class="kwrd"&gt;new&lt;/span&gt; Mock&amp;lt;IDbDataParameter&amp;gt;().Object);

    &lt;span class="kwrd"&gt;string&lt;/span&gt; calledCommand = &lt;span class="str"&gt;&amp;quot;&amp;quot;&lt;/span&gt;;
    _command.SetupSet(cmd =&amp;gt; cmd.CommandText)
        .Callback(cmd =&amp;gt; calledCommand = cmd);

     &lt;span class="rem"&gt;// act&lt;/span&gt;
    _target.Single&amp;lt;DummyClass&amp;gt;(1);

    &lt;span class="rem"&gt;// assert&lt;/span&gt;
    Assert.AreEqual(&lt;span class="str"&gt;&amp;quot;select * from dummyclasses where id = @id&amp;quot;&lt;/span&gt;, calledCommand);
}&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;This is really knowing too much about the internals of Dapper, but that's how I ended up. An alternative approach to test this would be to create a virtual method Query&amp;lt;T&amp;gt; in the repository that calls Dapper's Query&amp;lt;T&amp;gt; method, and in testing using a subclass of the repository and override that method to get the command that I'm trying to execute.&lt;/p&gt;</description><pubDate>Fri, 20 Jul 2012 19:26:20 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/jaimedelpalacio/testing-code-that-uses-dapper-1-10</guid></item><item><title>A way to organize your javascript code</title><link>https://weblogs.asp.net:443/jaimedelpalacio/a-way-to-organize-your-javascript-code</link><description>&lt;p&gt;I while back I got tired of having to include bootstrapping code on all my html (aspx) pages; you know, including some sort of $(document).ready(…) to bind the correct set of handlers for the page, so I came up with a basic routing/bootstrapper to handle this in a more generic way. &lt;/p&gt;  &lt;p&gt;The basic idea is to have an object that takes care of calling the correct method on the correct object to initialize the bindings (and anything else that needs to happen on page load) based on the URL of the page, a routing engine :). &lt;/p&gt;  &lt;p&gt;Let’s say I’m using ASP.Net MVC, then I could organize my code so that I have one js object per controller and inside it a function for each of the actions to do the actual bootstrapping:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The controller object&lt;/strong&gt;&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 800px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;function&lt;/span&gt; () {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt;     myApplication.controllers.home = &lt;span style="color: #0000ff"&gt;function&lt;/span&gt;() {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/* controller initialization */&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.init = &lt;span style="color: #0000ff"&gt;function&lt;/span&gt;() {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;             alert(&lt;span style="color: #006080"&gt;'Hello from the controller.init function for the Home controller'&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;         &lt;span style="color: #008000"&gt;/* index action init function */&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.index = &lt;span style="color: #0000ff"&gt;function&lt;/span&gt;() {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;             alert(&lt;span style="color: #006080"&gt;'hello from index action in the home controller'&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt; })();&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Now when the user hits my “/Home/Index” URL, I need to call the appropriate methods on the controller object, and here it is:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The basic routing object&lt;/strong&gt;&lt;/p&gt;

&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 800px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #008000"&gt;/*---------------------------------------------------------*/&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; &lt;span style="color: #008000"&gt;/* The routing strategy */&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;function&lt;/span&gt; (app, $) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; st = {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;         strategies: {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;             mvc: {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;                 defaultController: &lt;span style="color: #006080"&gt;'home'&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;                 defaultAction: &lt;span style="color: #006080"&gt;'index'&lt;/span&gt;,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;                 controller: &lt;span style="color: #0000ff"&gt;function&lt;/span&gt; controllerFromUrl() {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;                     &lt;span style="color: #008000"&gt;// match urls in the form ../controllerName/actionName or ../controllerName&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;                     &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; ctl = document.location.href.match(/http[s]?:\/\/[\w\:\.\-\d]+\/([\w\d\-]+)[\/|$]/i);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;                     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; ctl ? ctl[1].toLowerCase() : &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.defaultController;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;                 },&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;                 action: &lt;span style="color: #0000ff"&gt;function&lt;/span&gt; actionFromUrl() {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;                     &lt;span style="color: #008000"&gt;// match urls in the form ../controllerName/actionName or ../controllerName&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;                     &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; act = document.location.href.match(/http[s]?:\/\/[\w\:\.\-\d]+\/[\w\d\-]+\/([\w\d\-]+)/i);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;                     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; act ? act[1].toLowerCase() : &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.defaultAction;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;                 }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;     };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt;     window.myApplication = $.extend(app, st);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum24"&gt;  24:&lt;/span&gt; })(window.myApplication || {}, jQuery);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum25"&gt;  25:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum26"&gt;  26:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum27"&gt;  27:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum28"&gt;  28:&lt;/span&gt; &lt;span style="color: #008000"&gt;/*--------------------------------------------*/&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum29"&gt;  29:&lt;/span&gt; &lt;span style="color: #008000"&gt;/* The basic routing object */&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum30"&gt;  30:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum31"&gt;  31:&lt;/span&gt; (&lt;span style="color: #0000ff"&gt;function&lt;/span&gt; (app, $) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum32"&gt;  32:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; opts = {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum33"&gt;  33:&lt;/span&gt;         routingStrategy: app.strategies.mvc&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum34"&gt;  34:&lt;/span&gt;     };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum35"&gt;  35:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum36"&gt;  36:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; theApp = {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum37"&gt;  37:&lt;/span&gt;         activeController: undefined,&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum38"&gt;  38:&lt;/span&gt;         controllers: {},&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum39"&gt;  39:&lt;/span&gt;         run: &lt;span style="color: #0000ff"&gt;function&lt;/span&gt; () {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum40"&gt;  40:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.initController();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum41"&gt;  41:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.initAction();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum42"&gt;  42:&lt;/span&gt;         },&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum43"&gt;  43:&lt;/span&gt;         initController: &lt;span style="color: #0000ff"&gt;function&lt;/span&gt; () {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum44"&gt;  44:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; activeControllerName =  opts.routingStrategy.controller(); &lt;span style="color: #008000"&gt;/*getCurrentControllerName*/&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum45"&gt;  45:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (activeControllerName &amp;amp;&amp;amp; &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.controllers[activeControllerName]) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum46"&gt;  46:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.activeController = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.controllers[activeControllerName]();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum47"&gt;  47:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.activeController.init();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum48"&gt;  48:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum49"&gt;  49:&lt;/span&gt;         },&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum50"&gt;  50:&lt;/span&gt;         initAction: &lt;span style="color: #0000ff"&gt;function&lt;/span&gt; () {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum51"&gt;  51:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;var&lt;/span&gt; activeActionName = opts.routingStrategy.action(); &lt;span style="color: #008000"&gt;/*getCurrentActionName*/&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum52"&gt;  52:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (activeActionName &amp;amp;&amp;amp; &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.activeController &amp;amp;&amp;amp; &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.activeController[activeActionName]) {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum53"&gt;  53:&lt;/span&gt;                  &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.activeController[activeActionName]();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum54"&gt;  54:&lt;/span&gt;             }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum55"&gt;  55:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum56"&gt;  56:&lt;/span&gt;     };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum57"&gt;  57:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum58"&gt;  58:&lt;/span&gt;     &lt;span style="color: #008000"&gt;/* pusblish the routing object */&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum59"&gt;  59:&lt;/span&gt;     window.myApplication = $.extend(app, theApp);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum60"&gt;  60:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum61"&gt;  61:&lt;/span&gt; })(window.myApplication || {}, jQuery);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum62"&gt;  62:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum63"&gt;  63:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum64"&gt;  64:&lt;/span&gt; $(&lt;span style="color: #0000ff"&gt;function&lt;/span&gt; () {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum65"&gt;  65:&lt;/span&gt;     myApplication.run();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum66"&gt;  66:&lt;/span&gt; });&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The way this works is by keeping a &lt;em&gt;list&lt;/em&gt; of controllers and match the current URL’s controller name to the controller object and call the init() function on it, then match the action part of the URL a function inside the controller object and, if it exists, call it.&lt;/p&gt;

&lt;p&gt;I’ve separated the part that decides the name of the controller and the action to a different object (routing strategy) so you could create a different strategy to decide the controller and action (ie. if you are not using MVC, you could use the name of the aspx page as the controller and something else for the action).&lt;/p&gt;

&lt;p&gt;The advantage of this approach is that I could have one file for each of my js controllers neatly organized and then, during my build process combine all of them into one and minimize it.&lt;/p&gt;

&lt;p&gt;After using this approach for a while, someone pointed out to me that this is a similar approach to &lt;a href="http://paulirish.com/2009/markup-based-unobtrusive-comprehensive-dom-ready-execution/"&gt;Paul Irish's unobstructive DOM-ready execution&lt;/a&gt; which uses the body id and class attributes as the basis for selecting the what to initialize, it’s also a very good way to handle the same problem, take a look at it also.&lt;/p&gt;

&lt;p&gt;So have fun with it!&lt;/p&gt;

&lt;a href="https://github.com/jaimedp/jqRoute"&gt;Source code on GitHub&lt;/a&gt;</description><pubDate>Wed, 23 Mar 2011 20:26:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/jaimedelpalacio/a-way-to-organize-your-javascript-code</guid><category>asp.net</category><category>client-side routing</category><category>javascript</category><category>jquery</category></item><item><title>Unit testing a legacy ASP.NET application. A personal journey – part 1</title><link>https://weblogs.asp.net:443/jaimedelpalacio/unit-testing-a-legacy-asp-net-application-a-personal-journey-part-1</link><description>&lt;p&gt;These series of posts will cover my journey into getting a legacy (i.e. no unit tests) ASP.NET web application under automated unit test coverage, the goals, decisions, techniques and pitfalls we got into as we rolled out this initiative.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The context&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;One of the products of the company I work for is a SaaS application that was developed in ASP.NET in the early days of v2.0. As a SaaS provider we are always making improvements to the application and adding new functionality as our clients and the market requires.&lt;/p&gt;  &lt;p&gt;The application is not that big, it has about 500k lines of code but it’s data intensive and makes extensive use of strongly typed data sets and table adapters as the data layer and extensive use of ASP.NET server controls in the presentation layer.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Why did we wanted to do this?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;As our application is constantly changing and being developed, we constantly ran into the all too familiar problems and growing pains:&lt;/p&gt;  &lt;p&gt;- Bugs were being introduced into one part of the system when we changed other parts of the system&lt;/p&gt;  &lt;p&gt;- We always broke a couple of features (always the same ones) whenever we added a new feature&lt;/p&gt;  &lt;p&gt;- Developers duplicating a bunch of code because they didn’t want to change/break existing code&lt;/p&gt;  &lt;p&gt;- Growing list of manual test cases that sometimes (ok most of the time) where not all executed resulting in publishing the application with trivial bugs&lt;/p&gt;  &lt;p&gt;- Manual testing is painful!&lt;/p&gt;  &lt;p&gt;- We wanted to refactor a bunch of ugly large methods, but we were afraid to break something&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;How did we start doing it&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;When we decided to start adding unit tests, the first thing we did was to compile everything under .net 3.5, since some of the tools we wanted to use depended on 3.5. Also, we decided on the tools that we would be using:&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Tools and Infrastructure&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;We decided to go with the following set of tools&lt;/p&gt;  &lt;p&gt;- &lt;a href="http://msdn.microsoft.com/en-us/library/ms182489(VS.80).aspx" target="_blank"&gt;MSTests&lt;/a&gt; as the test framework, since it was already in the IDE and cover our initial test requirements (IDE integration, &lt;a href="http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET" target="_blank"&gt;CruiseControl&lt;/a&gt; integration, existing experience in our team)&lt;/p&gt;  &lt;p&gt;- &lt;a href="http://structuremap.sourceforge.net/Default.htm" target="_blank"&gt;StructureMap&lt;/a&gt; as a &lt;a href="http://www.hanselman.com/blog/ListOfNETDependencyInjectionContainersIOC.aspx" target="_blank"&gt;DI container&lt;/a&gt;. Simple, effective, no cost&lt;/p&gt;  &lt;p&gt;- &lt;a href="http://code.google.com/p/moq/" target="_blank"&gt;Moq&lt;/a&gt; as our mocking framework. Simple, effective, no cost&lt;/p&gt;  &lt;p&gt;- Include unit testing in our continuous integration process. Obviously there’s no point in having tests if your not going to use them!&lt;/p&gt;  &lt;p&gt;- &lt;a href="http://testdriven.net/" target="_blank"&gt;TestDriven.net&lt;/a&gt; and nConver to track our progress&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Processes &lt;/em&gt;&lt;/p&gt;  &lt;p&gt;- We would start with our business layer and extend to the presentation and custom DAL code as possible.&lt;/p&gt;  &lt;p&gt;- Any new feature would have to include unit tests (and promote the use of &lt;a href="http://en.wikipedia.org/wiki/Test-driven_development" target="_blank"&gt;TDD&lt;/a&gt; for those features)&lt;/p&gt;  &lt;p&gt;- Any bug, would have to be first reproduced by a unit test and then fixed making the test pass&lt;/p&gt;  &lt;p&gt;- Code review any new test not just to catch errors but to spread the knowledge on what and how to write tests&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Armed with these tools and processes we set off into writing our first test. To figure out what king of problems we would have in breaking dependencies, we picked one of the simple business classes that manage Categories in our application and set off to write a test for the Delete method.&lt;/p&gt;  &lt;p&gt;The original method looked like this:&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;div&gt;   &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;     &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; Delete(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; categoryId)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     CategoriesDataTable dt = Adapter.GetCategoryById(categoryId, &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;         CompanyBLL.GetCurrentCompanyId());&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (dt.Count != 1)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;     CategoriesRow r = dt[0];&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;     r.Delete();&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; Adapter.Update(dt) == 1;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Simple enough. We ask the instance of the TableAdapter for the category to make sure it exists in the database, we mark it as deleted and update the DataTable into the database. The problem comes with the dependencies on the Adapter (a property that holds the instance of the TableAdapter) and the call to the static method CompanyBLL.GetCurrentCompanyId()&lt;/p&gt;

&lt;p&gt;To break these dependencies we had to do a few things:&lt;/p&gt;

&lt;p&gt;1. First STOP CALLING STATIC METHODS! We knew this was going to bite us every time, because it was used this way all over the application, so it was a good time to have a better solution, we created a RequestContext class that implemented an IRequestContext interface to abstract all the per request data that every class in the business layer needed and it started like this:&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;interface&lt;/span&gt; IRequestContext&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; CurrentCompanyId { get; }&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Afterwards we added some other methods to abstract the parts of the HttpContext that we were using like IsUserInRole, etc. but this was enough for our first case. &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;2. Then we created a new constructor for the CategoriesBLL class to inject the dependencies and modified the default constructor to create the concrete classes that we were using in production:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; CategoriesBLL(IRequestContext context, CategoriesTableAdapter adapter)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     m_context = context;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     m_adapter = adapter;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt; }&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; CategoriesBLL()&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;     : &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; WebRequestContext(), &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; CategoriesTableAdapter())&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;I know, &lt;a href="http://www.lostechies.com/blogs/chad_myers/archive/2009/07/14/just-say-no-to-poor-man-s-dependency-injection.aspx" target="_blank"&gt;poor man’s dependency injection&lt;/a&gt;, but we wanted to change as little as possible to be able to get our test running. Later on we would use &lt;a href="http://structuremap.sourceforge.net/Default.htm" target="_blank"&gt;StructureMap&lt;/a&gt; to resolve the dependencies and get rid of the extra constructor.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;3. Now we could change the Delete method to use the injected instances instead of the static method&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; Delete(&lt;span style="color: #0000ff"&gt;int&lt;/span&gt; CategoryId)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     CategoriesDataTable dt = m_adapter.GetCategoryById(CategoryId,&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;         m_context.CurrentCompanyId);&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (dt.Count != 1)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;     CategoriesRow r = dt[0];&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;     r.Delete();&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; Adapter.Update(dt) == 1;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;And at last we had something we could write a test against. Our first test!&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; [TestMethod]&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; DeleteCategory_WithExistingCategory_ShouldReturnTrue()&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     &lt;span style="color: #008000"&gt;// create a valid datatable with one category with id = 1&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;     var dt = CreateAValidCategory(1);&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;     &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;     &lt;span style="color: #008000"&gt;// set up the mock/stub objects&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;     m_adapter.Setup(a=&amp;gt;a.GetCategoryById(1)).Returns(dt).Verifiable();&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;     m_context.SetupGet(a =&amp;gt; a.CurrentCompanyId).Returns(1).Verifiable();&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; res = bll.Delete(1);&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt;     Assert.IsTrue(res);&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt;     m_context.VerifyAll();&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  15:&lt;/span&gt;     m_adapter.Verify(a=&amp;gt;a.Update(It.IsAny(CategoriesDataTable)), Times.Once());&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  16:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;And it passed! Well nice but no cigar, this was the first stab at it and we already started to learn a lot about how we were going to have to change our code base in order to make things testable. After a few more refactors / tests we got to grips with how, in general, we would have to refactor our business layer code base to make it testable, and I can say that it was a fairly simple thing to do once we got going, and the team was really excited about the whole thing, they finally were able to refactor code with a good level of confidence. &lt;/p&gt;

&lt;p&gt;Probably the best reference on testing legacy code is Michael Feathers’ book &lt;a href="http://www.amazon.com/Working-Effectively-Legacy-Michael-Feathers/dp/0131177052" target="_blank"&gt;Working Effectively with Legacy Code&lt;/a&gt; also he’s article &lt;a href="http://www.objectmentor.com/resources/articles/WorkingEffectivelyWithLegacyCode.pdf" target="_blank"&gt;Working Effectively With Legacy Code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;In the next post I’ll write on how we incorporated StructureMap into the application and injected the dependencies on the aspx and ascx classes to call the business logic and start removing the poor man’s DI.&lt;/p&gt;</description><pubDate>Sat, 17 Oct 2009 20:09:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/jaimedelpalacio/unit-testing-a-legacy-asp-net-application-a-personal-journey-part-1</guid><category>asp.net</category><category>legacy application</category><category>TableAdapters</category><category>unit test</category></item><item><title>Custom HTML Dropdown control (part 2) - The server control</title><link>https://weblogs.asp.net:443/jaimedelpalacio/custom-html-dropdown-control-part-2-the-server-control</link><description>&lt;p&gt;In this part we are going to take the custom DropDown html control that we 
created in &lt;a href="http://weblogs.asp.net/jaimedelpalacio/archive/2008/11/22/custom-html-dropdown-control-part-1.aspx"&gt;part 
1&lt;/a&gt; and create an ASP.NET server control so we can use it in our Web 
Forms.&lt;/p&gt;
&lt;p&gt;The control in &lt;a href="http://weblogs.asp.net/jaimedelpalacio/archive/2008/11/22/custom-html-dropdown-control-part-1.aspx"&gt;part 
1&lt;/a&gt; was a fully working drop down control that behaves very close to the 
regular &amp;lt;select&amp;gt; html control but, if you set a specific width to the 
control, it expands the list of options to show the full width of the options in 
IE6 &amp;amp; 7 (which does not happen with the regular select html control).&lt;/p&gt;
&lt;p&gt;To create a server control for our drop down, we are going to inherit from 
the regular DropDownList control to get all its databinding functionality and we 
are going to override some of the rendering members to emit a different html 
markup. We also going to implement IPostBackDataHandler to manage the post back 
data. So our class declaration will be:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;partial&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;class&lt;/span&gt; DropDownSelect : DropDownList, IPostBackDataHandler&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;The Markup&lt;/h2&gt;
&lt;p&gt;Then we override the RenderBeginTag to emit the same markup as we created it 
in &lt;a href="http://weblogs.asp.net/jaimedelpalacio/archive/2008/11/22/custom-html-dropdown-control-part-1.aspx"&gt;part 
1&lt;/a&gt;:&lt;/p&gt;
&lt;div&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; RenderBeginTag(HtmlTextWriter writer)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// render the wrapper div for the full control&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;     writer.WriteBeginTag(&lt;span style="color: rgb(0, 96, 128);"&gt;"div"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"ID"&lt;/span&gt;, ClientID);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"Name"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.UniqueID);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (!&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;.IsNullOrEmpty(CssClass))&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;         writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"class"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"controlWrapper "&lt;/span&gt; + CssClass);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;         writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"class"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"controlWrapper"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  15:&lt;/span&gt;     writer.Write(&lt;span style="color: rgb(0, 96, 128);"&gt;"&amp;gt;"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  16:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  17:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// textbox, arrow and hiiden value field&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  18:&lt;/span&gt;     RenderTextBoxSpan(writer);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  19:&lt;/span&gt; }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  20:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  21:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;private&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; RenderTextBoxSpan(HtmlTextWriter writer)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  22:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  23:&lt;/span&gt;     writer.WriteBeginTag(&lt;span style="color: rgb(0, 96, 128);"&gt;"div"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  24:&lt;/span&gt;     writer.Write(&lt;span style="color: rgb(0, 96, 128);"&gt;"&amp;gt;"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  25:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  26:&lt;/span&gt;     writer.WriteBeginTag(&lt;span style="color: rgb(0, 96, 128);"&gt;"span"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  27:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (!&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;.IsNullOrEmpty(CssClass))&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  28:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  29:&lt;/span&gt;         writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"class"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"textBoxWrapper "&lt;/span&gt; + CssClass);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  30:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  31:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  32:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  33:&lt;/span&gt;         writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"class"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"textBoxWrapper"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  34:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  35:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  36:&lt;/span&gt;     writer.Write(&lt;span style="color: rgb(0, 96, 128);"&gt;"&amp;gt;"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  37:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  38:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// text box&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  39:&lt;/span&gt;     writer.WriteBeginTag(&lt;span style="color: rgb(0, 96, 128);"&gt;"input"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  40:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"ID"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.ClientID + &lt;span style="color: rgb(0, 96, 128);"&gt;"_ddText"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  41:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"Name"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.UniqueID + &lt;span style="color: rgb(0, 96, 128);"&gt;"$ddText"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  42:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"type"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"text"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  43:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"readonly"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  44:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  45:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (!&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt;.IsNullOrEmpty(CssClass))&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  46:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  47:&lt;/span&gt;         writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"class"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"ddTextBox "&lt;/span&gt; + CssClass);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  48:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  49:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  50:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  51:&lt;/span&gt;         writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"class"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"ddTextBox"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  52:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  53:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"style"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"width:"&lt;/span&gt; + Width.ToString());&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  54:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  55:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// set the value in the textbox if we have any&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  56:&lt;/span&gt;     ListItem item = &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Items.FindByValue(SelectedValue);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  57:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (item != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  58:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  59:&lt;/span&gt;         writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"value"&lt;/span&gt;, item.Text);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  60:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  61:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  62:&lt;/span&gt;     writer.Write(&lt;span style="color: rgb(0, 96, 128);"&gt;" /&amp;gt;"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  63:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  64:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// open dropdown arrow&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  65:&lt;/span&gt;     writer.WriteBeginTag(&lt;span style="color: rgb(0, 96, 128);"&gt;"img"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  66:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"src"&lt;/span&gt;, Page.ClientScript.GetWebResourceUrl(&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  67:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;typeof&lt;/span&gt;(DropDownSelect), &lt;span style="color: rgb(0, 96, 128);"&gt;"DropDownSelect.Images.downArrow.gif"&lt;/span&gt;));&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  68:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"align"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"texttop"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  69:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"ID"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.ClientID + &lt;span style="color: rgb(0, 96, 128);"&gt;"_btnOpenDropDown"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  70:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"class"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"arrowImg"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  71:&lt;/span&gt;     writer.Write(&lt;span style="color: rgb(0, 96, 128);"&gt;" /&amp;gt;"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  72:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  73:&lt;/span&gt;     writer.WriteEndTag(&lt;span style="color: rgb(0, 96, 128);"&gt;"span"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  74:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  75:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// clearing div so the listbox does not show in the wrong place&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  76:&lt;/span&gt;     writer.WriteBeginTag(&lt;span style="color: rgb(0, 96, 128);"&gt;"div"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  77:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"style"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"clear:both;"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  78:&lt;/span&gt;     writer.Write(&lt;span style="color: rgb(0, 96, 128);"&gt;"&amp;gt;"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  79:&lt;/span&gt;     writer.WriteEndTag(&lt;span style="color: rgb(0, 96, 128);"&gt;"div"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  80:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  81:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// ending textbox wrapper div&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  82:&lt;/span&gt;     writer.WriteEndTag(&lt;span style="color: rgb(0, 96, 128);"&gt;"div"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  83:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  84:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// hidden value field&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  85:&lt;/span&gt;     writer.WriteBeginTag(&lt;span style="color: rgb(0, 96, 128);"&gt;"input"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  86:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"Id"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.ClientID + &lt;span style="color: rgb(0, 96, 128);"&gt;"_ddValue"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  87:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"Name"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.UniqueID);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  88:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"type"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"text"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  89:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"style"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"display:none;"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  90:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (item != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  91:&lt;/span&gt;         writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"value"&lt;/span&gt;, item.Value);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  92:&lt;/span&gt;     writer.Write(&lt;span style="color: rgb(0, 96, 128);"&gt;" /&amp;gt;"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  93:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  94:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// listbox wrapper div&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  95:&lt;/span&gt;     writer.WriteLine();&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  96:&lt;/span&gt;     writer.WriteBeginTag(&lt;span style="color: rgb(0, 96, 128);"&gt;"div"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  97:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"ID"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.ClientID + &lt;span style="color: rgb(0, 96, 128);"&gt;"_listBox"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  98:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"class"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"listBox"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  99:&lt;/span&gt;     writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"tabindex"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"0"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 100:&lt;/span&gt;     writer.Write(&lt;span style="color: rgb(0, 96, 128);"&gt;"&amp;gt;"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 101:&lt;/span&gt;     writer.WriteLine();&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 102:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 103:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// opening ul... the rest is rendered in the RenderContents()&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 104:&lt;/span&gt;     writer.WriteFullBeginTag(&lt;span style="color: rgb(0, 96, 128);"&gt;"ul"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt; 105:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Nothing really special here, we created the same markup as in part 1 up to 
where the data for the options has to be inserted... and that's the job of the 
RenderContents member so we override that one too, and create a &amp;lt;li&amp;gt; for 
each option:&lt;/p&gt;
&lt;div&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; RenderContents(HtmlTextWriter writer)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;     ListItemCollection items = &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Items;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;for&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;int&lt;/span&gt; j = 0; j &amp;lt; items.Count; j++)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;         ListItem item = items[j];&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;         writer.WriteBeginTag(&lt;span style="color: rgb(0, 96, 128);"&gt;"li"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;         writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"itemVal"&lt;/span&gt;, item.Value, &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;         writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"itemIndex"&lt;/span&gt;, j.ToString(), &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (item.Selected)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;         {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  15:&lt;/span&gt;             writer.WriteAttribute(&lt;span style="color: rgb(0, 96, 128);"&gt;"selected"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"selected"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  16:&lt;/span&gt;         }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  17:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  18:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (item.Attributes != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; item.Attributes.Count &amp;gt; 0)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  19:&lt;/span&gt;         {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  20:&lt;/span&gt;             item.Attributes.Render(writer);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  21:&lt;/span&gt;         }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  22:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  23:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Page != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  24:&lt;/span&gt;         {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  25:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.Page.ClientScript.RegisterForEventValidation(&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  26:&lt;/span&gt;                 &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.UniqueID, item.Value);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  27:&lt;/span&gt;         }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  28:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  29:&lt;/span&gt;         writer.Write(&lt;span style="color: rgb(0, 96, 128);"&gt;"&amp;gt;"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  30:&lt;/span&gt;         HttpUtility.HtmlEncode(item.Text, writer);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  31:&lt;/span&gt;         writer.WriteEndTag(&lt;span style="color: rgb(0, 96, 128);"&gt;"li"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  32:&lt;/span&gt;         writer.WriteLine();&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  33:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  34:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Note that we are using the Items collection from the DropDownList base 
control so all the functionality for databinding, and accessing the items 
collection still works the same, we are just emitting new html. Then we need to 
render the closing html tags for our control, and that is done in the 
RenderEndTag member:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; RenderEndTag(HtmlTextWriter writer)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// end of the ul of items&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;     writer.WriteEndTag(&lt;span style="color: rgb(0, 96, 128);"&gt;"ul"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// end of the listbox div&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;     writer.WriteEndTag(&lt;span style="color: rgb(0, 96, 128);"&gt;"div"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// end of the control div&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;     writer.WriteEndTag(&lt;span style="color: rgb(0, 96, 128);"&gt;"div"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&lt;br&gt;In &lt;a href="http://weblogs.asp.net/jaimedelpalacio/archive/2008/11/22/custom-html-dropdown-control-part-1.aspx"&gt;part 
1&lt;/a&gt;, we needed to re-hook all the javascript events on every postback, in this 
part I've upgraded the code to use jquery 1.3.2 and the new&amp;nbsp; .live event hook 
functionality, which means we don't have to re-hook all the javascript events, 
we just need to initialize the control once. We emit the script for that in the 
PreRender step:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; OnPreRender(EventArgs e)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;.OnPreRender(e);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// we need to register a script to initialize the dropdown and for a &lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// strange quirk in IE with the css of the dropdown, we need to hide all&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// list boxes on every post back&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (!Page.IsPostBack)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; script = &lt;span style="color: rgb(0, 96, 128);"&gt;@"&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;         var dd = new listBoxInstance('" + &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.ClientID + &lt;span style="color: rgb(0, 96, 128);"&gt;@"', "&lt;/span&gt; + &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;               &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.AutoPostBack.ToString().ToLower() + &lt;span style="color: rgb(0, 96, 128);"&gt;@");&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dd.doInit();&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;         ";&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  15:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  16:&lt;/span&gt;         ScriptManager.RegisterStartupScript(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.GetType(), &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  17:&lt;/span&gt;             &lt;span style="color: rgb(0, 96, 128);"&gt;"registerDropDownHandlers"&lt;/span&gt; + &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.ClientID, script, &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  18:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  19:&lt;/span&gt;         script = &lt;span style="color: rgb(0, 96, 128);"&gt;@"var prm = Sys.WebForms.PageRequestManager.getInstance(); &lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  20:&lt;/span&gt;         prm.add_endRequest(EndRequest);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  21:&lt;/span&gt;         function EndRequest(sender, args)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  22:&lt;/span&gt;         {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  23:&lt;/span&gt;             $('div[id*=_listBox]').css('display','none');&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  24:&lt;/span&gt;         }";&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  25:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  26:&lt;/span&gt;         ScriptManager.RegisterStartupScript(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.GetType(), &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  27:&lt;/span&gt;             &lt;span style="color: rgb(0, 96, 128);"&gt;"closeDropDowns"&lt;/span&gt;, script, &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  28:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  29:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now, you may notice that we are registering a closeDropDown script also, the 
problem is that in IE there's a strange behavior when you set the initial state 
of the list of options (the listbox) to display:none: when you display it, it 
does not stretches&amp;nbsp; correctly and does not show the overflow scrolls correctly, 
so we just hide it on every postback.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;The Postback data&lt;/h2&gt;
&lt;p&gt;The only extra thing we need to do is handle the postback data in our control 
by implementing the IPostBackDataHandler interface&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;bool&lt;/span&gt; LoadPostData(&lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; postDataKey, NameValueCollection postCollection)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// get the new selected value from the postback data collection&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// and if it's different from the current one, select it onto our property&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// and return true, so we get a RisePostDataChangedEvent call&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; newSelectedValue = postCollection[postDataKey];&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (newSelectedValue != &lt;span style="color: rgb(0, 0, 255);"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (newSelectedValue != SelectedValue)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;         {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;             SelectedValue = newSelectedValue;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;         }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  15:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  16:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  17:&lt;/span&gt; }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  18:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  19:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;public&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;new&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; RaisePostDataChangedEvent()&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  20:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  21:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.OnSelectedIndexChanged(EventArgs.Empty);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  22:&lt;/span&gt; }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  23:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When our control generates a postback, we get called on the LoadPostData with 
the values of the postback, so if the selected value has changed, we change it 
and return true, so the framework calls the RaisePostDataChangedEvent&lt;/p&gt;
&lt;p&gt;One last thing we need to do and that has to do with the way DropDownList 
control handles the SelectedValue and SelectedIndex properties. Before we bind 
the data to our control using the base class, we need to remember our 
SelectedValue and set it back after the binding. During the binding step, the 
DropDownList control uses an internal cache for selected items that we (at the 
derived class) don't have access, so it will try to set the SelectedValue from 
that cache and there's where we loose our selection, so we do:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;protected&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;override&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;void&lt;/span&gt; PerformDataBinding(IEnumerable dataSource)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// for some reason (it has to do with the cachedSelectedIndex in the DropDownList)&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// we need to preserve the selectedValue before the databind and then re-set it &lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// after the call to the base PerformeDataBinding&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;string&lt;/span&gt; selectedValue = SelectedValue;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;base&lt;/span&gt;.PerformDataBinding(dataSource);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;     SelectedValue = selectedValue;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And that's it for the server control class. I've also updated the javascript 
to use jquery 1.3.2 and the live events:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div style="border-style: none; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   1:&lt;/span&gt; &lt;span style="color: rgb(0, 128, 0);"&gt;// Initializes the dropdown and hooks the events&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   2:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt; init() {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   3:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; baseId = &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.baseClientId;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   4:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; shouldPostBack = &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.autoPostBack;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   5:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; $baseDiv = $(&lt;span style="color: rgb(0, 96, 128);"&gt;'#'&lt;/span&gt; + baseId);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   6:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; $items = $(&lt;span style="color: rgb(0, 96, 128);"&gt;'div[id*=_listBox] ul li'&lt;/span&gt;, $baseDiv);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   7:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; $listBox = $(&lt;span style="color: rgb(0, 96, 128);"&gt;'div[id*=_listBox]'&lt;/span&gt;, $baseDiv);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   8:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; $ddText = $(&lt;span style="color: rgb(0, 96, 128);"&gt;'input[id*=_ddText]'&lt;/span&gt;, $(&lt;span style="color: rgb(0, 96, 128);"&gt;'#'&lt;/span&gt; + baseId));&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;   9:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; $ddValue = $(&lt;span style="color: rgb(0, 96, 128);"&gt;'input[id*=_ddValue]'&lt;/span&gt;, $baseDiv);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  10:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; $btn = $(&lt;span style="color: rgb(0, 96, 128);"&gt;'img[id*=_btnOpenDropDown]'&lt;/span&gt;, $(&lt;span style="color: rgb(0, 96, 128);"&gt;'#'&lt;/span&gt; + baseId));&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  11:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  12:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; minWidth = $ddText.outerWidth() + $btn.outerWidth();&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  13:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; offset = $ddText.eq(0).offset().left - 1;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  14:&lt;/span&gt;     $listBox.css(&lt;span style="color: rgb(0, 96, 128);"&gt;"display"&lt;/span&gt;, &lt;span style="color: rgb(0, 96, 128);"&gt;"none"&lt;/span&gt;);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  15:&lt;/span&gt;     FixIeHeight($items.length, $listBox)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  16:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  17:&lt;/span&gt;     $btn.live(&lt;span style="color: rgb(0, 96, 128);"&gt;"click"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;() {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  18:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; $baseDiv = $(&lt;span style="color: rgb(0, 96, 128);"&gt;'#'&lt;/span&gt; + baseId);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  19:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; $listBox = $(&lt;span style="color: rgb(0, 96, 128);"&gt;'div[id*=_listBox]:hidden'&lt;/span&gt;, $baseDiv);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  20:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  21:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; ($listBox.length &amp;gt; 0) {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  22:&lt;/span&gt;             $listBox.css(&lt;span style="color: rgb(0, 96, 128);"&gt;"left"&lt;/span&gt;, offset).css(&lt;span style="color: rgb(0, 96, 128);"&gt;"min-width"&lt;/span&gt;, minWidth);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  23:&lt;/span&gt;             $listBox.show();&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  24:&lt;/span&gt;             $listBox.scrollTop(0).focus();&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  25:&lt;/span&gt;             BindHoverAndBlur(baseId);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  26:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  27:&lt;/span&gt;         }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  28:&lt;/span&gt;     });&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  29:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  30:&lt;/span&gt;     $items.live(&lt;span style="color: rgb(0, 96, 128);"&gt;"click"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;(e) {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  31:&lt;/span&gt;         HideItemList(baseId);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  32:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; $baseDiv = $(&lt;span style="color: rgb(0, 96, 128);"&gt;'#'&lt;/span&gt; + baseId);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  33:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; $ddText = $(&lt;span style="color: rgb(0, 96, 128);"&gt;'input[id*=_ddText]'&lt;/span&gt;, $baseDiv);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  34:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; $ddValue = $(&lt;span style="color: rgb(0, 96, 128);"&gt;'input[id*=_ddValue]'&lt;/span&gt;, $baseDiv);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  35:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  36:&lt;/span&gt;         $ddText.val($(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;).text());&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  37:&lt;/span&gt;         $ddValue.val($(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;).attr(&lt;span style="color: rgb(0, 96, 128);"&gt;"itemVal"&lt;/span&gt;));&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  38:&lt;/span&gt;         $ddText.select();&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  39:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (shouldPostBack)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  40:&lt;/span&gt;             setTimeout(&lt;span style="color: rgb(0, 96, 128);"&gt;'__doPostBack(\''&lt;/span&gt; + baseId.replace(/_/g, &lt;span style="color: rgb(0, 96, 128);"&gt;'$'&lt;/span&gt;) + &lt;span style="color: rgb(0, 96, 128);"&gt;'\',\'selectedindexchanged\')'&lt;/span&gt;, 0);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  41:&lt;/span&gt;     });&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  42:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  43:&lt;/span&gt;     $ddText.live(&lt;span style="color: rgb(0, 96, 128);"&gt;"click"&lt;/span&gt;, &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;() {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  44:&lt;/span&gt;         $(&lt;span style="color: rgb(0, 96, 128);"&gt;'img[id*=_btnOpenDropDown]'&lt;/span&gt;, $(&lt;span style="color: rgb(0, 96, 128);"&gt;'#'&lt;/span&gt; + baseId)).click();&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  45:&lt;/span&gt;     });&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  46:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  47:&lt;/span&gt; }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  48:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  49:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt; listBoxInstance(clientId, autoPostBack) {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  50:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.baseClientId = clientId;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  51:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.wasBlur = &lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  52:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.autoPostBack = autoPostBack;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  53:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.doInit = init;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  54:&lt;/span&gt; }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  55:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  56:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt; BindHoverAndBlur(baseId) {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  57:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; $baseDiv = $(&lt;span style="color: rgb(0, 96, 128);"&gt;'#'&lt;/span&gt; + baseId);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  58:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; $listBox = $(&lt;span style="color: rgb(0, 96, 128);"&gt;'div[id*=_listBox]'&lt;/span&gt;, $baseDiv);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  59:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  60:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// very ugly way to detect IE6... we should use jQuery.support&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  61:&lt;/span&gt;     &lt;span style="color: rgb(0, 128, 0);"&gt;// but haven't found a way to detect the anything:hover feature support&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  62:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt;( isIe6()) {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  63:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; $items = $(&lt;span style="color: rgb(0, 96, 128);"&gt;'div[id*=_listBox] ul li'&lt;/span&gt;, $baseDiv);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  64:&lt;/span&gt;         $items.hover(&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  65:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;() { $(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;).addClass(&lt;span style="color: rgb(0, 96, 128);"&gt;"highLight"&lt;/span&gt;); },&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  66:&lt;/span&gt;             &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;() { $(&lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;).removeClass(&lt;span style="color: rgb(0, 96, 128);"&gt;"highLight"&lt;/span&gt;); }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  67:&lt;/span&gt;         );&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  68:&lt;/span&gt;         FixIeHeight($items.length, $listBox);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  69:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  70:&lt;/span&gt;     $listBox.blur(&lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt;(e) {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  71:&lt;/span&gt;         HideItemList(baseId);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  72:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;this&lt;/span&gt;.wasBlur = &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  73:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  74:&lt;/span&gt;     });&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  75:&lt;/span&gt; }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  76:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  77:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt; FixIeHeight(itemsCount, div) {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  78:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (isIe6()) {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  79:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; h;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  80:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; (itemsCount &amp;gt; 10)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  81:&lt;/span&gt;             h = &lt;span style="color: rgb(0, 96, 128);"&gt;"10em"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  82:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;else&lt;/span&gt;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  83:&lt;/span&gt;             h = &lt;span style="color: rgb(0, 96, 128);"&gt;"auto"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  84:&lt;/span&gt;         div.css(&lt;span style="color: rgb(0, 96, 128);"&gt;"height"&lt;/span&gt;, h);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  85:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  86:&lt;/span&gt; }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  87:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  88:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt; HideItemList(baseId) {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  89:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;var&lt;/span&gt; $listBox = $(&lt;span style="color: rgb(0, 96, 128);"&gt;'div[id*=_listBox]:visible'&lt;/span&gt;, $(&lt;span style="color: rgb(0, 96, 128);"&gt;'#'&lt;/span&gt; + baseId));&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  90:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; ($listBox.length &amp;gt; 0)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  91:&lt;/span&gt;         $listBox.hide(10);&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  92:&lt;/span&gt; }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  93:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  94:&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;function&lt;/span&gt; isIe6() {&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  95:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;if&lt;/span&gt; ($.browser.msie &amp;amp;&amp;amp; $.browser.version.substr(0) &amp;lt;= 6)&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  96:&lt;/span&gt;         &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  97:&lt;/span&gt;     &lt;span style="color: rgb(0, 0, 255);"&gt;return&lt;/span&gt; &lt;span style="color: rgb(0, 0, 255);"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: rgb(244, 244, 244);"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  98:&lt;/span&gt; }&lt;/pre&gt;&lt;pre style="border-style: none; margin: 0em; padding: 0px; overflow: visible; font-size: 8pt; width: 100%; color: black; line-height: 12pt; font-family: consolas,'Courier New',courier,monospace; background-color: white;"&gt;&lt;span style="color: rgb(96, 96, 96);"&gt;  99:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You'll notice that I embedded the css, image and javascript in the same 
package so you just need one dll for the whole thing to work. &lt;/p&gt;
&lt;p&gt;You can download the full server control code &lt;a href="http://cid-f11bde7e36485844.skydrive.live.com/self.aspx/blog/DropDownSelect/DropDownSelect.zip" target="_blank"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;h2&gt;Improvements&lt;/h2&gt;
&lt;p&gt;Some improvements could still be made to the control:&lt;/p&gt;
&lt;p&gt;- I don't really like the fact that I had to include some browser specific 
code in the javascript to work around some IE6 bugs/missing functionality&lt;/p&gt;
&lt;p&gt;- Still fills a bit sluggish when you have a lot of options in the drop down, 
so some optimizations may improve this.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div class="wlWriterEditableSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:1bfecd89-b845-47ef-ac56-a6b18f699be5" style="margin: 0px; padding: 0px; display: inline; float: none;" contenteditable="false"&gt;LiveJournal 
Tags: &lt;a href="http://www.livejournal.com/interests.bml?int=asp.net" rel="tag"&gt;asp.net&lt;/a&gt;,&lt;a href="http://www.livejournal.com/interests.bml?int=dropdown" rel="tag"&gt;dropdown&lt;/a&gt;,&lt;a href="http://www.livejournal.com/interests.bml?int=custom%20server%20control" rel="tag"&gt;custom server control&lt;/a&gt;&lt;/div&gt;</description><pubDate>Sun, 01 Mar 2009 19:47:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/jaimedelpalacio/custom-html-dropdown-control-part-2-the-server-control</guid><category>asp.net</category><category>custom controls</category><category>dropdown</category><category>jquery</category><category>server control</category></item><item><title>Custom HTML Dropdown control (part 1)</title><link>https://weblogs.asp.net:443/jaimedelpalacio/custom-html-dropdown-control-part-1</link><description>&lt;P&gt;My problem stated with the fact that if you set a width to a dropdown (select) control, IE clips the contents of a drop down list when expanded.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE class="" cellSpacing=0 cellPadding=2 width=600 border=0&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=600&gt;IE 7&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=600&gt;&lt;IMG src="http://tqcyaw.bay.livefilestore.com/y1pBRJhrPM3c-1AUfww9qr1unicpTwO9T0cyQbzKWPJSNLa6ZZ2qqTlYA155A-1zJ-rxbvvc-L0p0Q/image25.png" mce_src="http://tqcyaw.bay.livefilestore.com/y1pBRJhrPM3c-1AUfww9qr1unicpTwO9T0cyQbzKWPJSNLa6ZZ2qqTlYA155A-1zJ-rxbvvc-L0p0Q/image25.png"&gt;&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=600&gt;Firefox 3&lt;/TD&gt;&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="" vAlign=top width=600&gt;&lt;IMG src="http://tqcyaw.bay.livefilestore.com/y1pyyUjXAY6l36gmGnLt0Wgy_MXESxSOqJZ3-p8l-r-habhz3-5Dw5mVDhAjJdhYPtVmVXWyWNU5G8/image33.png" mce_src="http://tqcyaw.bay.livefilestore.com/y1pyyUjXAY6l36gmGnLt0Wgy_MXESxSOqJZ3-p8l-r-habhz3-5Dw5mVDhAjJdhYPtVmVXWyWNU5G8/image33.png"&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To solve this, I decided to create my own custom dropdown control and as a bonus be able to add some more custom functionality like ComboBox features, more visual effects, etc.&amp;nbsp; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The basic principle is to have two text boxes (one for the selected text and another one hidden for the selected value), a down arrow button to show the list of options and a div that shows the options. All this peppered with some javascript (using jquery to ease things up) to control the behavior.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;The Text boxes&lt;/B&gt; &lt;B&gt;&amp;amp; button&lt;/B&gt;&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas,'Courier New',courier,monospace; BACKGROUND-COLOR: rgb(244,244,244)"&gt;
&lt;DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   1:&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;div&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   2:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;span&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="textBoxWrapper"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   3:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;input&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;type&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="text"&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;id&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="ddText"&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="ddTextBox"&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;readonly&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   4:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;img&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;src&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="gfx/downArrow.gif"&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;id&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="btn"&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;align&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="texttop"&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="arrowImg"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   5:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;span&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   6:&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;div&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   7:&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;input&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;id&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="ddValue"&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;type&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="text"&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;style&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="display:none;"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The first textbox (ddText) will hold the selected text, the second textbox (ddValue) will hold the value attribute of the selected item (if any) so it can be retrieved from the server side; and all these is wrapped in a span and a div. We need outer div to be able to make the span floated and having the whole control work as expected.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;The list of options&lt;/B&gt;&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas,'Courier New',courier,monospace; BACKGROUND-COLOR: rgb(244,244,244)"&gt;
&lt;DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   1:&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;div&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;id&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="listBox"&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;class&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="listBox"&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;style&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="display:none;"&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;tabindex&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="0"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   2:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;ul&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   3:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;li&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;value&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="1"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;Item 1 with a lot of stuff to make it bigger&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;li&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   4:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;li&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;value&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="2"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;Item 2 a little shorter&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;li&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   5:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;li&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;value&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="3"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;Item 3&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;li&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   6:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;li&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;value&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="4"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;Item 4&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;li&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   7:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;li&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;value&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="5"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;Item 5&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;li&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   8:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;li&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;value&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="6"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;Item 6&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;li&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   9:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;li&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;value&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="7"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;Item 7&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;li&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  10:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;li&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(255,0,0)"&gt;value&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;="8"&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;Item 8&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;li&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  11:&lt;/SPAN&gt;     &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;ul&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  12:&lt;/SPAN&gt; &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(128,0,0)"&gt;div&lt;/SPAN&gt;&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;The list of options is a regular div with an unorder list to hold the options. The only two special things about this code are the tabindex="0" property of the div that will help us workaround a problem with the OnBlur event on firefox not firing, and the non-standard "value" attribute of the list items.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With all these code we'll have the following control:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://tqcyaw.bay.livefilestore.com/y1pyyUjXAY6l34YgroRIcumOoiYKtg1sW1NYGk4gx9CekDaZD7PWeUt5dHmXeqwV5DEJiuHiQbp3c4/image48.png" mce_src="http://tqcyaw.bay.livefilestore.com/y1pyyUjXAY6l34YgroRIcumOoiYKtg1sW1NYGk4gx9CekDaZD7PWeUt5dHmXeqwV5DEJiuHiQbp3c4/image48.png"&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;Styling the control&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;The wrapper and text boxes&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas,'Courier New',courier,monospace; HEIGHT: 260px; BACKGROUND-COLOR: rgb(244,244,244)"&gt;
&lt;DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   1:&lt;/SPAN&gt; .textBoxWrapper {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   2:&lt;/SPAN&gt;     border:solid 1px #7F9DB9;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   3:&lt;/SPAN&gt;     padding:0;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   4:&lt;/SPAN&gt;     white-space:nowrap;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   5:&lt;/SPAN&gt;     height:1em;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   6:&lt;/SPAN&gt; }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   7:&lt;/SPAN&gt; .ddTextBox {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   8:&lt;/SPAN&gt;     border:solid 0px white;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   9:&lt;/SPAN&gt;     width:120px;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  10:&lt;/SPAN&gt;     padding-left:.2em;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  11:&lt;/SPAN&gt;     cursor:arrow;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  12:&lt;/SPAN&gt; }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  13:&lt;/SPAN&gt; .arrowImg {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  14:&lt;/SPAN&gt;     margin:1px;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  15:&lt;/SPAN&gt; }&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;The wrapper simple has a solid border with no padding and the white-space:nowrap will prevent the img from wrapping below the textbox.&lt;/P&gt;
&lt;P&gt;Nothing special in the ddTextBox, we just remove the border (since we added the border to the span wrapped around the textbox and down arrow), set the width as desired and add some padding to make it look good, and we end up with this:&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://tqcyaw.bay.livefilestore.com/y1ppeReElWt0vbjpuVrCqUvkTi9dTH652eYmt3BovO-3xbQIdmVGAu2Kmof5A711-JRSjiiC00Gdeg/image52.png" mce_src="http://tqcyaw.bay.livefilestore.com/y1ppeReElWt0vbjpuVrCqUvkTi9dTH652eYmt3BovO-3xbQIdmVGAu2Kmof5A711-JRSjiiC00Gdeg/image52.png"&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The styles for the list of options look like this:&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas,'Courier New',courier,monospace; BACKGROUND-COLOR: rgb(244,244,244)"&gt;
&lt;DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   1:&lt;/SPAN&gt; .listBox {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   2:&lt;/SPAN&gt;     height:100px;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   3:&lt;/SPAN&gt;     overflow-y:auto;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   4:&lt;/SPAN&gt;     overflow-x:hidden;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   5:&lt;/SPAN&gt;     border:solid 1px black;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   6:&lt;/SPAN&gt;     background-color:white;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   7:&lt;/SPAN&gt;     white-space:nowrap;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   8:&lt;/SPAN&gt;     float:left;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   9:&lt;/SPAN&gt;     position:absolute;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  10:&lt;/SPAN&gt; }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  11:&lt;/SPAN&gt; .listBox ul {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  12:&lt;/SPAN&gt;     margin:0px;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  13:&lt;/SPAN&gt;     padding:0px;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  14:&lt;/SPAN&gt;     list-style-type:none;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  15:&lt;/SPAN&gt; }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  16:&lt;/SPAN&gt; .listBox ul li {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  17:&lt;/SPAN&gt;     cursor:arrow;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  18:&lt;/SPAN&gt;     padding-left:.2em;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  19:&lt;/SPAN&gt;     padding-right:1.3em;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  20:&lt;/SPAN&gt; }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  21:&lt;/SPAN&gt; .highLight {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  22:&lt;/SPAN&gt;     background-color:#316ac5;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  23:&lt;/SPAN&gt;     color:white;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  24:&lt;/SPAN&gt; }&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P&gt;The special things here are the overflow-y:auto to show the scroll bar if the content is greater than the defined height, and the float:left and position:absolute so it shows on top of the other elements on the page as expected. The rest of the classes are to format the &amp;lt;ul&amp;gt; and &amp;lt;li&amp;gt; elements and to highLight the options when we hover over them.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And that's all its needed to format our drop down for now&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://tqcyaw.bay.livefilestore.com/y1pz6tO3nx7ehX440KWOv6-MWyxE_Y4ohHhsnAxZ8joqaVUUr3Lt-ru7LqD674mrhghvihCNjHTLe0/image55.png" mce_src="http://tqcyaw.bay.livefilestore.com/y1pz6tO3nx7ehX440KWOv6-MWyxE_Y4ohHhsnAxZ8joqaVUUr3Lt-ru7LqD674mrhghvihCNjHTLe0/image55.png"&gt; &lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;B&gt;The script&lt;/B&gt;&lt;/P&gt;
&lt;P&gt;Now all the magic happens in a set of javascript functions to handle the different events for our control:&lt;/P&gt;
&lt;DIV style="BORDER-RIGHT: gray 1px solid; PADDING-RIGHT: 4px; BORDER-TOP: gray 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 8pt; PADDING-BOTTOM: 4px; MARGIN: 20px 0px 10px; OVERFLOW: auto; BORDER-LEFT: gray 1px solid; WIDTH: 97.5%; CURSOR: text; LINE-HEIGHT: 12pt; PADDING-TOP: 4px; BORDER-BOTTOM: gray 1px solid; FONT-FAMILY: consolas,'Courier New',courier,monospace; BACKGROUND-COLOR: rgb(244,244,244)"&gt;
&lt;DIV style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   1:&lt;/SPAN&gt; &amp;lt;script src=&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;"js/jquery-1.2.6.min.js"&lt;/SPAN&gt; type=&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;"text/javascript"&lt;/SPAN&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   2:&lt;/SPAN&gt; &amp;lt;script type=&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;"text/javascript"&lt;/SPAN&gt;&amp;gt;&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   3:&lt;/SPAN&gt;     $(document).ready(&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;function&lt;/SPAN&gt;() {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   4:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;var&lt;/SPAN&gt; $items = $(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;'#listBox ul li'&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   5:&lt;/SPAN&gt;         &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;var&lt;/SPAN&gt; $listBox = $(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;'#listBox'&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   6:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   7:&lt;/SPAN&gt;         $(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;'#btn'&lt;/SPAN&gt;).click(&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;function&lt;/SPAN&gt;() {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   8:&lt;/SPAN&gt;             &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;var&lt;/SPAN&gt; minWidth = $(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;'#ddText'&lt;/SPAN&gt;).outerWidth() + $(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;'#btn'&lt;/SPAN&gt;).outerWidth();&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;   9:&lt;/SPAN&gt;             $listBox.css(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;"left"&lt;/SPAN&gt;,$(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;'#ddText'&lt;/SPAN&gt;).eq(0).offset().left).css(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;"min-width"&lt;/SPAN&gt;,minWidth);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  10:&lt;/SPAN&gt;             &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;if&lt;/SPAN&gt;($listBox.css(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;"display"&lt;/SPAN&gt;)==&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;"none"&lt;/SPAN&gt;) {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  11:&lt;/SPAN&gt;                 $listBox.show(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;"fast"&lt;/SPAN&gt;, &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;function&lt;/SPAN&gt;() {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  12:&lt;/SPAN&gt;                     $listBox.scrollTop(0).eq(0).focus();&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  13:&lt;/SPAN&gt;                 });&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  14:&lt;/SPAN&gt;             }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  15:&lt;/SPAN&gt;             &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;else&lt;/SPAN&gt; {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  16:&lt;/SPAN&gt;                 $listBox.hide(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;"fast"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  17:&lt;/SPAN&gt;             }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  18:&lt;/SPAN&gt;         });&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  19:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  20:&lt;/SPAN&gt;         $items.click(&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;function&lt;/SPAN&gt;(e) {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  21:&lt;/SPAN&gt;             $(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;'#ddText'&lt;/SPAN&gt;).val($(&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;this&lt;/SPAN&gt;).text());&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  22:&lt;/SPAN&gt;             $(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;'#ddValue'&lt;/SPAN&gt;).val($(&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;this&lt;/SPAN&gt;).attr(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;"value"&lt;/SPAN&gt;));&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  23:&lt;/SPAN&gt;             $listBox.hide(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;"fast"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  24:&lt;/SPAN&gt;         });&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  25:&lt;/SPAN&gt;         &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  26:&lt;/SPAN&gt;         $(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;'#ddText'&lt;/SPAN&gt;).click(&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;function&lt;/SPAN&gt;() {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  27:&lt;/SPAN&gt;             $(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;'#btn'&lt;/SPAN&gt;).click();&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  28:&lt;/SPAN&gt;         });&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  29:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  30:&lt;/SPAN&gt;         $items.hover(&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;function&lt;/SPAN&gt;() {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  31:&lt;/SPAN&gt;                 $(&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;this&lt;/SPAN&gt;).addClass(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;"highLight"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  32:&lt;/SPAN&gt;             }, &lt;SPAN style="COLOR: rgb(0,0,255)"&gt;function&lt;/SPAN&gt;() {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  33:&lt;/SPAN&gt;                 $(&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;this&lt;/SPAN&gt;).removeClass(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;"highLight"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  34:&lt;/SPAN&gt;             }&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  35:&lt;/SPAN&gt;         );&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  36:&lt;/SPAN&gt;&amp;nbsp; &lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  37:&lt;/SPAN&gt;         $listBox.blur(&lt;SPAN style="COLOR: rgb(0,0,255)"&gt;function&lt;/SPAN&gt;(e) {&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  38:&lt;/SPAN&gt;             $listBox.hide(&lt;SPAN style="COLOR: rgb(0,96,128)"&gt;"fast"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  39:&lt;/SPAN&gt;         });&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: rgb(244,244,244); BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  40:&lt;/SPAN&gt;     });&lt;/PRE&gt;&lt;PRE style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; FONT-SIZE: 8pt; PADDING-BOTTOM: 0px; MARGIN: 0em; OVERFLOW: visible; WIDTH: 100%; COLOR: black; BORDER-TOP-STYLE: none; LINE-HEIGHT: 12pt; PADDING-TOP: 0px; FONT-FAMILY: consolas,'Courier New',courier,monospace; BORDER-RIGHT-STYLE: none; BORDER-LEFT-STYLE: none; BACKGROUND-COLOR: white; BORDER-BOTTOM-STYLE: none"&gt;&lt;SPAN style="COLOR: rgb(96,96,96)"&gt;  41:&lt;/SPAN&gt; &amp;lt;/script&amp;gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When the btn.click event fires (the user click on the down arrow) we need to adjust the position of the listbox to be be below the textbox and show the div&lt;/P&gt;
&lt;P&gt;When the user selects and item, we'll get the selected text and selected value and set them to the corresponding textBoxes, and hide the list box&lt;/P&gt;
&lt;P&gt;When the hover event happens on the options we simple swap in and out the highLight class.&lt;/P&gt;
&lt;P&gt;When the the user clicks on anything else on the page outside the list box (onblur) we need to hide the listbox without making a selection.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And that's it! we have a fully functional drop down that corrects the IE clipping problem and is ready to extend as we want (ie. combobox functionality, finer control over style, autocomplete, etc.).&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the next part we'll convert this into a server control to bind it to some server data and maybe we can add some combo box functionality.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the complete source click &lt;A href="https://skydrive.live.com/embed?cid=F11BDE7E36485844&amp;resid=F11BDE7E36485844%21149" mce_href="https://skydrive.live.com/embed?cid=F11BDE7E36485844&amp;resid=F11BDE7E36485844%21149"&gt;here&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: Next part is &lt;A href="http://weblogs.asp.net/jaimedelpalacio/archive/2009/03/01/custom-html-dropdown-control-part-2-the-server-control.aspx" mce_href="/jaimedelpalacio/archive/2009/03/01/custom-html-dropdown-control-part-2-the-server-control.aspx"&gt;The Server Control&lt;/A&gt; &lt;BR&gt;&lt;/P&gt;</description><pubDate>Sat, 22 Nov 2008 18:23:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/jaimedelpalacio/custom-html-dropdown-control-part-1</guid><category>asp.net</category><category>custom controls</category><category>dropdown</category><category>jquery</category></item><item><title>MySql and Tableadapters</title><link>https://weblogs.asp.net:443/jaimedelpalacio/mysql-and-tableadapters</link><description>&lt;P&gt;Update (5/5/2008): You can download the Visual Basic version of the code &lt;A class="" title=here href="https://aspblogs.blob.core.windows.net/media/jaimedelpalacio/Media/CustomerExDAL.vb.txt" target=_blank mce_href="https://aspblogs.blob.core.windows.net/media/jaimedelpalacio/Media/CustomerExDAL.vb.txt"&gt;here&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I think writing data access code is one of the most boring and tedious tasks in computer programming, so I welcome any help I can get to avoid doing it. That's were TableAdapters come in. Now if you want to use MySql as your database of choice using the MySql Connector/Net, you have a little problem with the auto-generated Tableadapters: they don't have an update/insert/delete commands so you cannot update/insert/delete (depending on what version of the connector you are using, you may get the insert command but not the update). This is due to a bug that is supposed to be fixed in version 5.2.2 (for VS2008). Anyway this is a workaround until MySql get's the connector fixed.&lt;/P&gt;
&lt;P&gt;The trick is that the TableAdapter classes that Visual Studio/the Connector generates are marked as partial classes, sp we can extend the class and add the functionality that is missing (aka Update/Insert/Delete) ourselves. Since we are going to be adding some code by hand to the TableAdapter, the first thing we need to do is tell Visual Studio not to generate the Update commands by going into the advance options of the main query of the TableAdapter and uncheck the "Generate Insert, Update and Delete statements" &lt;/P&gt;
&lt;P&gt;&lt;A href="https://aspblogs.blob.core.windows.net/media/jaimedelpalacio/WindowsLiveWriter/Test_FCB5/image_2.png" mce_href="https://aspblogs.blob.core.windows.net/media/jaimedelpalacio/WindowsLiveWriter/Test_FCB5/image_2.png"&gt;&lt;IMG style="MARGIN: 0px 0px 0px 30px" height=461 alt=image src="https://aspblogs.blob.core.windows.net/media/jaimedelpalacio/WindowsLiveWriter/Test_FCB5/image_thumb.png" width=586 border=0 mce_src="https://aspblogs.blob.core.windows.net/media/jaimedelpalacio/WindowsLiveWriter/Test_FCB5/image_thumb.png"&gt;&lt;/A&gt; &lt;/P&gt;
&lt;P&gt;Now we need to create a partial class that will be named exactly the same as our generated class. For example, if my table adapter is called Products, the class that is generated will be called ProductsTableAdapter and will be in the namespace &lt;EM&gt;MyDataSet&lt;/EM&gt;TableAdapters where MyDataSet is the name of your xsd data set. &lt;/P&gt;
&lt;P&gt;The class will have at least two new methods. The first one I'll call PrepareCommands and will be in charge of setting up the CommandBuilder so we get the update/insert/delete commands sorted out:&lt;/P&gt;&lt;PRE class=csharpcode&gt;    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;partial&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; productsTableAdapter
    {
        &lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;bool&lt;/SPAN&gt; m_isInitialized = &lt;SPAN class=kwrd&gt;false&lt;/SPAN&gt;;

        &lt;SPAN class=kwrd&gt;private&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; PrepareCommands()
        {
            &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (!m_isInitialized)
            {
                &lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.ClearBeforeFill = &lt;SPAN class=kwrd&gt;true&lt;/SPAN&gt;;
                &lt;SPAN class=rem&gt;// get the table name from the generated table mappings&lt;/SPAN&gt;
                &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; tableName = Adapter.TableMappings[0].DataSetTable;
                &lt;SPAN class=rem&gt;// create a generic select command&lt;/SPAN&gt;
                Adapter.SelectCommand = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; MySql.Data.MySqlClient.MySqlCommand(
&lt;SPAN class=str&gt;			"Select * from "&lt;/SPAN&gt; + tableName, Connection);
                &lt;SPAN class=rem&gt;// now just by creating the commandbuidler associated with the adapter, we&lt;/SPAN&gt;
                &lt;SPAN class=rem&gt;// get the update, insert and delete commands&lt;/SPAN&gt;
                MySql.Data.MySqlClient.MySqlCommandBuilder cb = 
&lt;SPAN class=kwrd&gt;			new&lt;/SPAN&gt; MySql.Data.MySqlClient.MySqlCommandBuilder(Adapter);
                m_isInitialized = &lt;SPAN class=kwrd&gt;true&lt;/SPAN&gt;;
            }
        }&lt;/PRE&gt;
&lt;P&gt;Note that I'm checking if the TableAdapter hasn't been initialized before, since creating a CommandBuilder is very expensive (it actually has to query the database with the SelectCommand to get the schema) so we only want to do the PrepareCommands when is absolutely necessary. &lt;/P&gt;
&lt;P&gt;The next method we need is an Update that takes a typed dataTable as a parameter, in our case a MySqlDS.productsDataTable&lt;/P&gt;&lt;PRE class=csharpcode&gt;        [System.Diagnostics.DebuggerNonUserCodeAttribute()]
        [System.ComponentModel.Design.HelpKeywordAttribute(&lt;SPAN class=str&gt;"vs.data.TableAdapter"&lt;/SPAN&gt;)]
        &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;virtual&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; Update(MySqlDS.productsDataTable dataTable)
        {
            &lt;SPAN class=rem&gt;// call prepare commands to make sure we have the &lt;/SPAN&gt;
            &lt;SPAN class=rem&gt;// insert/update/delete commands set up &lt;/SPAN&gt;
            PrepareCommands();

            &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; res = 0;
            MySqlConnection conn = &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;;
            &lt;SPAN class=kwrd&gt;try&lt;/SPAN&gt;
            {
                &lt;SPAN class=rem&gt;// open the connection just in case it was not open by the time&lt;/SPAN&gt;
                &lt;SPAN class=rem&gt;// we get called&lt;/SPAN&gt;
                &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt;( Adapter.SelectCommand.Connection.State != ConnectionState.Open )
                {
                    &lt;SPAN class=rem&gt;// if we are opening the connection then we should close it! &lt;/SPAN&gt;
                    &lt;SPAN class=rem&gt;// so we store it in a local connection&lt;/SPAN&gt;
                    conn = Adapter.SelectCommand.Connection;
                    conn.Open();
                }
                res = &lt;SPAN class=kwrd&gt;this&lt;/SPAN&gt;.Adapter.Update(dataTable);
            }
            &lt;SPAN class=kwrd&gt;finally&lt;/SPAN&gt;
            {
                &lt;SPAN class=rem&gt;// if we open the connection we should close it&lt;/SPAN&gt;
                &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (conn != &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt; &amp;amp;&amp;amp; conn.State != ConnectionState.Closed)
                    conn.Close();
            }
            &lt;SPAN class=rem&gt;// we are done!&lt;/SPAN&gt;
            &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; res;
        }&lt;/PRE&gt;
&lt;STYLE type=text/css&gt;.csharpcode {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	FONT-SIZE: small; COLOR: black; FONT-FAMILY: consolas, "Courier New", courier, monospace; BACKGROUND-COLOR: #ffffff
}
.csharpcode PRE {
	MARGIN: 0em
}
.csharpcode .rem {
	COLOR: #008000
}
.csharpcode .kwrd {
	COLOR: #0000ff
}
.csharpcode .str {
	COLOR: #006080
}
.csharpcode .op {
	COLOR: #0000c0
}
.csharpcode .preproc {
	COLOR: #cc6633
}
.csharpcode .asp {
	BACKGROUND-COLOR: #ffff00
}
.csharpcode .html {
	COLOR: #800000
}
.csharpcode .attr {
	COLOR: #ff0000
}
.csharpcode .alt {
	MARGIN: 0em; WIDTH: 100%; BACKGROUND-COLOR: #f4f4f4
}
.csharpcode .lnum {
	COLOR: #606060
}
&lt;/STYLE&gt;

&lt;P&gt;And that's it, we have a MySql TableAdapter that can add, update and delete and we had to do minimal coding on the data access side. Just one thing, we could do with just that one Update method or we could add overloaded Update methods with DataTabe, DataRow and DataRow[] using the Adapter.Update method.&lt;/P&gt;
&lt;P&gt;So until we get a production level 5.2.2 Connector/Net from MySql we need to use some workarounds to make it work for us.&lt;/P&gt;</description><pubDate>Sat, 03 May 2008 23:23:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/jaimedelpalacio/mysql-and-tableadapters</guid><category>.net</category><category>asp.net</category><category>MySql</category><category>TableAdapters</category></item><item><title>UpdateProgress and disable a control on postback with multiple UpdatePanels</title><link>https://weblogs.asp.net:443/jaimedelpalacio/updateprogress-and-disable-a-control-on-postback-with-multiple-updatepanels</link><description>&lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;A few months ago, while upgrading an application to use ajax, I needed to show some feedback to the user on long running actions while disabling some of the controls on the page. Looking around for a solutions, I found a couple of good articles on &lt;a href="http://mattberseth.com/"&gt;Matt Berseth's&lt;/a&gt; blog about UpdateProgress animations that look promising so I decided to create an extender control to do just that. After I created the extender I found out that Matt had a &lt;a href="http://mattberseth.com/blog/2007/08/disable_updatepanel_contents_d.html"&gt;similar extender&lt;/a&gt; as well. Anyway the basic requirements were:&lt;/p&gt;  &lt;p&gt;- It must disable a group of controls specified at design time    &lt;br /&gt;- It must be able to provide feedback to the user (i.e. show a &amp;quot;Loading...&amp;quot; indicator)     &lt;br /&gt;- It must work on FireFox IE6 and IE7     &lt;br /&gt;- It must work for nested UpdatePanels     &lt;br /&gt;- It must work for strange css layouts (ie. positioning absolute/relative)&lt;/p&gt;  &lt;p&gt;The basic principle is to create a div that covers the group of controls that we want to disable, the same way the modal popup works (this could be a div, gridview, list, updatepanel, etc.), show it on the client side's beginRequest event and then hide it on the endRequest event. &lt;/p&gt;  &lt;p&gt;The first thing we need to do is to create the div element that will covert our target control and set some initial properties for it. We do this in the initialize function of our extender.&amp;#160;&amp;#160;&amp;#160; &lt;/p&gt;  &lt;pre class="csharpcode"&gt;        &lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement = $get(&lt;span class="str"&gt;&amp;quot;loadingExtenderBackgroundElement&amp;quot;&lt;/span&gt;);
        &lt;span class="kwrd"&gt;if&lt;/span&gt;( &lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement == &lt;span class="kwrd"&gt;null&lt;/span&gt; ) {
            &lt;span class="rem"&gt;// create a new div to place on top of the control we are updating...&lt;/span&gt;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement = document.createElement(&lt;span class="str"&gt;'div'&lt;/span&gt;);
            &lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement.id = &lt;span class="str"&gt;'loadingExtenderBackgroundElement'&lt;/span&gt;;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement.style.display = &lt;span class="str"&gt;'none'&lt;/span&gt;;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement.style.left = &lt;span class="str"&gt;'0px'&lt;/span&gt;;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement.style.top = &lt;span class="str"&gt;'0px'&lt;/span&gt;;

            &lt;span class="rem"&gt;// just define a zIndex big enough to sit on top of all the other elements&lt;/span&gt;
            &lt;span class="rem"&gt;// on the page&lt;/span&gt;
            &lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement.style.zIndex = 10000;
            &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;this&lt;/span&gt;._updatingCssClass) {
                &lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement.className = &lt;span class="kwrd"&gt;this&lt;/span&gt;._updatingCssClass;
            }&lt;/pre&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Note that we first check if we have created a div already, so we don't end up with lots of divs in our code. Next we need to set the position style for the div; usually we'd want to use 'fixed' so no matter what the scroll position is, we get the div position correctly, but IE6 doesn't support the fixed position so we change it for absolute&lt;/p&gt;

&lt;pre class="csharpcode"&gt;            &lt;span class="rem"&gt;// now since IE6 does not support the fixed position style, then we need to hack it a bit&lt;/span&gt;
            &lt;span class="rem"&gt;// to get it to show correctly on top of the element&lt;/span&gt;
            &lt;span class="kwrd"&gt;if&lt;/span&gt;( Sys.Browser.agent == Sys.Browser.InternetExplorer &amp;amp;&amp;amp; Sys.Browser.version &amp;lt; 7 ) {
                &lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement.style.position = &lt;span class="str"&gt;'absolute'&lt;/span&gt;;
            }
            &lt;span class="kwrd"&gt;else&lt;/span&gt; {
                &lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement.style.position = &lt;span class="str"&gt;'fixed'&lt;/span&gt;;
            }&lt;/pre&gt;

&lt;p&gt;and we add our div to the form element so we don't have to worry about offsetParent stuff.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre class="csharpcode"&gt;document.forms.item(0).appendChild(&lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement);&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now that we have our background div, we will change the zIndex and relative position in the DOM of the &amp;quot;loading...&amp;quot; div.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt;( &lt;span class="kwrd"&gt;this&lt;/span&gt;._loadingDiv ) {
            &lt;span class="kwrd"&gt;var&lt;/span&gt; upDiv = $get(&lt;span class="kwrd"&gt;this&lt;/span&gt;._loadingDiv);
            &lt;span class="kwrd"&gt;if&lt;/span&gt;( upDiv.parentNode != document.forms.item(0) ) {
                &lt;span class="kwrd"&gt;if&lt;/span&gt;( upDiv.parentNode.removeChild(upDiv) ) {
                    document.forms.item(0).appendChild(upDiv);
                }
            }
            upDiv.style.zIndex = &lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement.style.zIndex + 1;
        }&lt;/pre&gt;

&lt;p&gt;Finally we have to setup the handlers for the beginRequest, endRequest and pageLoaded&lt;/p&gt;

&lt;pre class="csharpcode"&gt;        &lt;span class="rem"&gt;// register the beginRequest and endRequest events using the AjaxToolbox.BehaviorBase            &lt;/span&gt;
        &lt;span class="kwrd"&gt;this&lt;/span&gt;.registerPartialUpdateEvents(); 
        &lt;span class="kwrd"&gt;this&lt;/span&gt;._pageLoadedHandler = Function.createDelegate(&lt;span class="kwrd"&gt;this&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;._pageLoaded);
        &lt;span class="kwrd"&gt;this&lt;/span&gt;._pageRequestManager.add_pageLoaded(&lt;span class="kwrd"&gt;this&lt;/span&gt;._pageLoadedHandler);&lt;/pre&gt;

&lt;p&gt;Now all that is left to do is, on the beginRequest, position and size the background div above the targetControl, show it and show and center the &amp;quot;Loading...&amp;quot; div; and hide everything on the endRequest event. The problem is that if we have two updatepanels on our page we'll still get called even if our targetControl is not being updated, so we will use the sender parameter of the beginRequest to determine the source of the postback, then we will try to $get our targetControl within the child control tree of the panel that is updating and if we get something back, it means that we are part of the updating panel and we need to disable our targetControl. The beginRequestHandler goes something like:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;        &lt;span class="rem"&gt;// find out who cased the postback and if the element is a child of the update panel&lt;/span&gt;
        &lt;span class="kwrd"&gt;var&lt;/span&gt; upId = &lt;span class="kwrd"&gt;this&lt;/span&gt;.getUpdatingElement(sender);
        &lt;span class="rem"&gt;// the ip comes as a UniqueID and we need to compare it the ControlID (you know the ctl001$myctl vs ctl001_myctl problem)&lt;/span&gt;
        &lt;span class="kwrd"&gt;var&lt;/span&gt; callingId = &lt;span class="kwrd"&gt;null&lt;/span&gt;;
        &lt;span class="kwrd"&gt;if&lt;/span&gt;( upId != &lt;span class="kwrd"&gt;null&lt;/span&gt; )
            callingId = upId.replace(/\$/g,&lt;span class="str"&gt;'_'&lt;/span&gt;);
        &lt;span class="rem"&gt;// only do all this if the element is part of the updaing panel&lt;/span&gt;
        &lt;span class="kwrd"&gt;var&lt;/span&gt; element = $get(&lt;span class="kwrd"&gt;this&lt;/span&gt;.get_element().id, $get(callingId));
        &lt;span class="kwrd"&gt;if&lt;/span&gt;(  element == &lt;span class="kwrd"&gt;null&lt;/span&gt; )
            &lt;span class="kwrd"&gt;return&lt;/span&gt; ;
            
        // so we are part of the update... show our panels&lt;/pre&gt;

&lt;p&gt;Now we just need to show and position our divs&lt;/p&gt;

&lt;pre class="csharpcode"&gt;        &lt;span class="kwrd"&gt;var&lt;/span&gt; progressDiv = $get(&lt;span class="kwrd"&gt;this&lt;/span&gt;._loadingDiv);
        &lt;span class="kwrd"&gt;if&lt;/span&gt;( &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(progressDiv) != &lt;span class="str"&gt;'undefined'&lt;/span&gt; )
        {
            &lt;span class="rem"&gt;// is important to show it before we get the bounds, otherwise, we'll get 0,0 for the width and height&lt;/span&gt;
            progressDiv.style.display = &lt;span class="str"&gt;'block'&lt;/span&gt;;
            
            &lt;span class="kwrd"&gt;var&lt;/span&gt; progBounds = Sys.UI.DomElement.getBounds(progressDiv);
            &lt;span class="rem"&gt;// now center the progress div onto the control&lt;/span&gt;
            &lt;span class="kwrd"&gt;var&lt;/span&gt; x = bounds.x + Math.round( ((bounds.width - progBounds.width) / 2));
            &lt;span class="kwrd"&gt;var&lt;/span&gt; y = bounds.y + Math.round( ((bounds.height - progBounds.height) / 2));
            Sys.UI.DomElement.setLocation (progressDiv, x, y);        
        }
        &lt;span class="rem"&gt;// show the div that covers the element&lt;/span&gt;
        &lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement.style.width = bounds.width + &lt;span class="str"&gt;'px'&lt;/span&gt;; &lt;span class="rem"&gt;// important to add the 'px' for fireFox&lt;/span&gt;
        &lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement.style.height = bounds.height + &lt;span class="str"&gt;'px'&lt;/span&gt;;
        Sys.UI.DomElement.setLocation (&lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement, bounds.x, bounds.y);
        &lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement.style.display = &lt;span class="str"&gt;'block'&lt;/span&gt;;&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;And that's it, in the endRequest we just hide everything and we are done.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;        &lt;span class="kwrd"&gt;if&lt;/span&gt;( &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(&lt;span class="kwrd"&gt;this&lt;/span&gt;._loadingDiv) != &lt;span class="str"&gt;'undefined'&lt;/span&gt;) {        
            &lt;span class="kwrd"&gt;var&lt;/span&gt; progressDiv = $get(&lt;span class="kwrd"&gt;this&lt;/span&gt;._loadingDiv);
            progressDiv.style.display = &lt;span class="str"&gt;'none'&lt;/span&gt;;
        }
        &lt;span class="kwrd"&gt;else&lt;/span&gt;
            alert(&lt;span class="str"&gt;'cant find progress div'&lt;/span&gt;);
        &lt;span class="kwrd"&gt;this&lt;/span&gt;._backgroundElement.style.display = &lt;span class="str"&gt;'none'&lt;/span&gt;;&lt;/pre&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;As you can see, we just have to add some checks here and there to be able to handle multiple UpdatePanels on the same page. Hope this helps someone save some coding time. &lt;/p&gt;

&lt;div class="wlWriterSmartContent" id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:b55c00a2-c322-49be-8cd7-ea67c97466d2" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;&lt;p&gt;To download the sample with the extender &lt;a href="https://aspblogs.blob.core.windows.net/media/jaimedelpalacio/WindowsLiveWriter/UpdateProgressanddisableacontrolonpostba_8E39/LoadingExtenderSample.zip" target="_blank"&gt;click here&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</description><pubDate>Sat, 03 May 2008 19:15:12 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/jaimedelpalacio/updateprogress-and-disable-a-control-on-postback-with-multiple-updatepanels</guid><category>asp.net</category><category>ControlExtender</category><category>UpdateProgress</category></item><item><title>Compatibility of bit type between SqlServer 2000 and SqlServer 2005</title><link>https://weblogs.asp.net:443/jaimedelpalacio/compatibility-of-bit-type-between-sqlserver-2000-and-sqlserver-2005</link><description>&lt;P&gt;Yesterday I had to debug an issue of a product that we are deploying to a production server. We were developing using SqlServer 2005 (express) and the hosting company uses SqlServer 2000 and as soon as we deploy, we got the following exception on one of the operations:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;"Syntax error converting the varchar value 'true' to a column of data type bit"&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;After some debugging (a couple of hours) and after deploying some special debugging versions, we found the issue. In SqlServer 2005, the following query is perfectly legal:&lt;/P&gt;
&lt;P&gt;SELECT UserId, Name FROM Users WHERE IsActive = 'true'&lt;/P&gt;
&lt;P&gt;(where IsActive is a bit type)&lt;/P&gt;
&lt;P&gt;As it turns out, this is not a valid query in SqlServer 2000, throwing above exception. Because of the single quote, SqlServer 2000, interprets the 'true' as a varchar and cannot cast it as bit, so you need to change it to:&lt;/P&gt;
&lt;P&gt;SELECT UserId, Name FROM Users WHERE IsActive = 1&lt;/P&gt;
&lt;P&gt;This query is valid in SqlServer 2005 and in SqlServer 2000.&lt;/P&gt;
&lt;P&gt;This may be something widely known, but it wasn't to me, so I hope this helps you save some debugging time.&lt;/P&gt;</description><pubDate>Tue, 29 Jan 2008 17:42:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/jaimedelpalacio/compatibility-of-bit-type-between-sqlserver-2000-and-sqlserver-2005</guid><category>bit type</category><category>compatibility</category><category>Sql Server</category></item><item><title>Kick-off</title><link>https://weblogs.asp.net:443/jaimedelpalacio/kick-off</link><description>&lt;p&gt;First of all, thanks to Joe Stagner and all the asp.net crew for giving us the opportunity to&amp;#160; contribute to this community. I'll be posting on different topics of Web Development and specially on Web Applications development. I'll try to post as often as possible so check back.&lt;/p&gt;  &lt;p&gt;I little about me. I've been programming professionally for more than 15 years on different areas ranging from game development to process automation to web applications. I'm currently COO at a Mexican software (SaaS) company and directly involved in the development/design of new products for our Software as Service model.&lt;/p&gt;</description><pubDate>Fri, 25 Jan 2008 00:28:00 GMT</pubDate><guid isPermaLink="true">https://weblogs.asp.net:443/jaimedelpalacio/kick-off</guid><category>General</category></item></channel></rss>