title: asp.net mvc, dropdownlist, jquery
body: <p>Hi folks hi have a very interesting situation.</p>
  
  <p>i have a viewmodel that requires a mediatype from a dropdownlist *by the way the dropdownlist is generated by </p>
  
  <pre><code>@Html.DropDownListFor(m =&gt; m.MediaType, Model.MediaTypeList)
  </code></pre>
  
  <p>and when i fill the form by hand all the values of the form are ok and the functions works the way it should.</p>
  
  <p>but then i implemented a jquery function to set the value of the dropdownlist whenever you upload a file it detects automatically what media type it has.</p>
  
  <pre><code>function setValueToDropDown(media){                                        
      $('#MediaType').attr('disabled','');   
      var value = media;
      $('#MediaType').val(value);   
  }
  </code></pre>
  
  <p>and when i submit the domain validations tell me that the field is required, even when the dropdownlist is option is selected and when i execute a function in console to verify the value it is different than null.</p>
  
  <pre><code>alert($('#MediaType').val()) 
  </code></pre>
  
  <p>so i dont understand why when im assigning the value to the dropdown dynamically mvc doesnt recognize it. i look everywhere and i cant find the problem.</p>