title: call to controller to populate text box based on dropdownlistfor selection using Ajax
body: <p>I have a dropdown and when I select an item from it, I want to pass on the selected value to a function in a controller, query the db and auto load a text box with query results.</p>
  
  <p>How do I use Ajax to make that call to the controller when there is onclick() event on the dropdown?</p>
  
  <p><strong>My dropdown and textbox in my aspx page is:</strong></p>
  
  <pre><code> &lt;%: Html.DropDownListFor(model =&gt; model.ApplicationSegmentGuid, Model.ApplicationSegment)%&gt;
  
     &lt;%: Html.TextAreaFor(model =&gt; model.EmailsSentTo, false, new { style = "width:500px;   height:50px;" })%&gt;
  </code></pre>
  
  <p><strong>My function in controller is</strong></p>
  
  <pre><code> public ActionResult AsyncFocalPoint(Nullable&lt;Guid&gt; ApplicationSegmentGuid)
      {
          string tempEmail = UnityHelper.Resolve&lt;IUserDirectory&gt;().EmailOf();
          tempEmail = "subbulakshmi.kailasam@lyondellbasell.com" + tempEmail;
  
          IList&lt;string&gt; EmailAddresses = new List&lt;String&gt;();
  
          using (TSADRequestEntities context = UnityHelper.Resolve&lt;TSADRequestEntities&gt;())
          {
              EmailAddresses = context.FOCALPOINTs.Where(T =&gt; T.APPLICATIONSEGMENT.ItemGuid == ApplicationSegmentGuid &amp;&amp; T.FlagActive)
                        .Select(T =&gt; T.Email).ToList();
          }
          foreach (string emailAddress in EmailAddresses)
              tempEmail = tempEmail + ";" + emailAddress;
  
          return Json(tempEmail, JsonRequestBehavior.AllowGet);
      }
  </code></pre>