title: MVC DropDownList Arrow style with css
body: <p>In my razor file, I am building a form.
  The form controls need to reflect the modelType of the razor page I have declared, in this case, "Case" is the name of the model.</p>
  
  <p>I have a Html helper DropDownList on the page for a property of case called PSCStatusID with this line:</p>
  
  <pre><code>    @Html.DropDownListFor(s =&gt; s.PSCStatusID, (SelectList)ViewBag.PSCStatusList, "&lt;--Select One--&gt;", new { @class = "form-control" })
  </code></pre>
  
  <p>This works perfectly for me with of course the validation kicking in from my POCO attributes.</p>
  
  <p>Notice I am sprinkling in Bootstrap css styles.  Actually the creative dept. handed off the HTML to me and I am trying to get it exact.</p>
  
  <p>But their version of my one liner HTML helper above is the following:</p>
  
  <pre><code>&lt;div class="input-group"&gt;
                              @Html.TextBoxFor(c =&gt; c.PSCStatusID, null, new { @class = "form-control" })
                              &lt;div class="input-group-btn"&gt;
                                  &lt;button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false"&gt;
                                      &lt;span class="caret"&gt;&lt;/span&gt;
                                  &lt;/button&gt;
                                  &lt;ul class="dropdown-menu dropdown-menu-nrsa-psc dropdown-menu-right" role="menu"&gt;
                                      @foreach (PSCStatus item in ViewBag.PSCStatusList)
                                      {
                                          &lt;li&gt;
  
                                              &lt;a href="#" onclick="document.getElementById('PSCStatusID').value = this.text;"&gt;
                                                  @item.StatusCode - @item.StatusTextDesc
                                              &lt;/a&gt;
                                          &lt;/li&gt;
                                      }
                                  &lt;/ul&gt;
                              &lt;/div&gt;
                          &lt;/div&gt;
  </code></pre>
  
  <p>So I know this is a common way these days for HTML people to display a custom dropdown and make that give that button mimicking the DropDown Arrow some bootstrap classes like class="btn btn-primary".</p>
  
  <p>But this is really messing me up.
  It doesn't work well with MVC.
  If I now name the textbox which mimicks the dropdown selectedText PSCStatusID, it contains the actual text and not the id.
  The list items aren't like select options with both text and a value.</p>
  
  <p>I would have to jump through a lot of hoops to make this work.</p>
  
  <p>All I really need to do is change that drop down arrow from the default to my own button looking drop down.</p>
  
  <p>I've come across a lot of css like:</p>
  
  <pre><code>select::ms-expand {display: none;}
  </code></pre>
  
  <p>That would make the arrow disappear in IE.</p>
  
  <p>And something like this:</p>
  
  <pre><code>select:after {
  content: "▼";  /* Current arrow I would like to change */
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  font-size: 60%;
  line-height: 30px;
  padding: 0 7px;
  background: #000;
  color: black;
  }
  </code></pre>
  
  <p>That shows an arrow but not in the select box.</p>
  
  <p>I just can't quite get it.</p>
  
  <p>Does anyone have any suggestions on how to do this?</p>
  
  <p>Here is what I have currently <img src="https://i.stack.imgur.com/OSWWs.jpg" alt="enter image description here"></p>
  
  <p>Notice my validation working out-of-the-box:)</p>
  
  <p>But this is what I need to get:
  <img src="https://i.stack.imgur.com/EclwK.jpg" alt="enter image description here"></p>
  
  <p>If any MVC/CSS gurus out there have an idea how to make this happen in my one liner HTML Helper verison of the drop down rather then the custom way please let me know.</p>
  
  <p>Actually this is the code they handed off to me.  The version I have above is where I swapped out some MVC controls for HTML:</p>
  
  <pre><code>&lt;div class="form-group"&gt;
                &lt;label for="nrsa-psc" class="col-sm-4 control-label"&gt;*NRSA PSC Status&lt;/label&gt;
                &lt;div class="col-sm-8"&gt;
                  &lt;div class="input-group"&gt;
                    &lt;input type="text" class="form-control" id="nrsa-psc"&gt;
                    &lt;div class="input-group-btn"&gt;
                      &lt;button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false"&gt;&lt;span class="caret"&gt;&lt;/span&gt;&lt;/button&gt;
                      &lt;ul class="dropdown-menu dropdown-menu-nrsa-psc dropdown-menu-right" role="menu"&gt;
                        &lt;li&gt;Option 1&lt;/li&gt;
                        &lt;li&gt;Option 2&lt;/li&gt;
                        &lt;li&gt;Option 3&lt;/li&gt;
                        &lt;li&gt;Option 4&lt;/li&gt;
                      &lt;/ul&gt;
                    &lt;/div&gt;&lt;!-- /btn-group --&gt;
                  &lt;/div&gt;
                &lt;/div&gt;
              &lt;/div&gt;
  </code></pre>
  
  <hr>
  
  <p>So got a little closer:</p>
  
  <p>I added the selectpicker class to the dropdown:</p>
  
  <pre><code>@Html.DropDownListFor(s =&gt; s.PSCStatusID, (SelectList)ViewBag.PSCStatusList, "&lt;--Select One--&gt;", new { @class = "form-control selectpicker" })
  </code></pre>
  
  <p>Then brought bootstrap select picker css and js from github.</p>
  
  <p>Then added:</p>
  
  <pre><code>.form-control.bootstrap-select.input-validation-error &gt; button { border: 1px solid #f00; background-color: #fee; }
  after:
  .input-validation-error { border: 1px solid #f00; background-color: #fee; } 
  </code></pre>
  
  <p>to get MVC validation working with the bootstrap select version of the drop down.</p>
  
  <p>And added:</p>
  
  <pre><code>span.caret{color: blue;}
  </code></pre>
  
  <p>By the way: why is it so hard to get lines to show up as code on this site.
  I hit four space all day long and it still shows up as regular text. They should make this easier - very annoying when trying to be a good citizen and post an answer.</p>