title: AjaxToolkit ModalPopupExtender: How do I set focus to a control in the popup Panel?
body: <p>When the user pushes the Button, I'd like to display a modal dialog box to capture a couple of values from text boxes and submit these values to the server. </p>
  
  <p>When the modal box is shown, I'd like the cursor to be placed in the txtFirst textbox. </p>
  
  <p>How do I do this? I've had trouble with registerscript commands before, so if one is needed, I hope the syntax, if you provide it, is correct. </p>
  
  <p>Thanks</p>
  
  <pre><code>&lt;%@ Page Language="VB" AutoEventWireup="false" CodeFile="MyModalSimple.aspx.vb" Inherits="MyModalSimple" %&gt;
  &lt;%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
  
      &lt;script type="text/javascript"&gt;
  
          function onOk() {            
              form1.submit();
          }
      &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;div&gt;
          &lt;asp:ScriptManager ID="ScriptManager1" runat="server"&gt;
          &lt;/asp:ScriptManager&gt;
          &lt;asp:Button ID="Button1" runat="server" Text="Button" /&gt;
          &lt;cc1:modalpopupextender id="Button1_ModalPopupExtender" runat="server" targetcontrolid="Button1"
              popupcontrolid="pnlModal" okcontrolid="btnOK" cancelcontrolid="btnCancel"   DropShadow="true"  OnOkScript="onOk();"&gt;
  
          &lt;/cc1:modalpopupextender&gt;
  
          &lt;asp:Panel ID="pnlModal" runat="server" Style="display: None1" 
              BackColor="#CCCCCC"&gt;
              &lt;br /&gt;
              &lt;table&gt;
                  &lt;tr&gt;
                      &lt;td&gt;
                          &lt;asp:Label ID="lblFirst" runat="server" Text="First"&gt;&lt;/asp:Label&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;asp:TextBox ID="txtFirst" runat="server"&gt;&lt;/asp:TextBox&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;
                          &lt;asp:Label ID="lblLast" runat="server" Text="Last"&gt;&lt;/asp:Label&gt;
                      &lt;/td&gt;
                      &lt;td&gt;
                          &lt;asp:TextBox ID="txtLast" runat="server"&gt;&lt;/asp:TextBox&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;
                          &amp;nbsp;
                      &lt;/td&gt;
                      &lt;td align="right"&gt;
                          &lt;asp:Button ID="btnOK" runat="server" Text="OK" /&gt;
                          &lt;asp:Button ID="btnCancel" runat="server" Text="Cancel" /&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
              &lt;br /&gt;
              &lt;br /&gt;
          &lt;/asp:Panel&gt;
  
      &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Also, how could I change the above code so that the modal dialog was displayed as a result of a <i>selection</i> of a dropdownlist item? If I set the targetcontrolid="DropDownList1", the dialog box is display when it drops rather than when  a selection is made</p>