title: How to set focus on textbox in other ContentPlaceHolder? - MVC2
body: <p>Greetings, </p>
  
  <p>I've been scanning the internet on how to do this, but so far no luck. There are numerous solutions posted, especially on this website (thank you for that), but none seem to work for me. This will most probably be because I am only learning asp.net since 4 months now, and lack the necessary knowledge.</p>
  
  <p>What I would like to do is set focus on the username input textbox when the page is loaded. I've seen many solutions, such as "defaultfocus", body onload, etc, etc. Anyone can give me a simple way to accomplish this?</p>
  
  <p>Our project is a MVC 2 Web application. We have a master site, which collects all the contentplaceholders. Here is the link to the logon.aspx</p>
  
  <pre><code>&lt;div id="Clogin" onclick="logout();"&gt;
      &lt;asp:ContentPlaceHolder ID="LoginContent" runat="server" /&gt;            
  &lt;/div&gt;
  </code></pre>
  
  <p>The LogOn.aspx is practically the same as the auto-generated one. And here is the textbox I would like to set focus on:</p>
  
  <pre><code>&lt;div class="login-field"&gt;
      &lt;%: Html.TextBoxFor(m =&gt; m.UserName)%&gt;
      &lt;%: Html.ValidationMessageFor(m =&gt; m.UserName) %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>How can I trigger the onload event, be it in the master page, or the LogOn page, so that the focus is generated on that particular textbox?</p>
  
  <p>Thanks in advance, and apologies for having to rely on your knowledge.</p>
  
  <p>Sincerely,</p>
  
  <p>Nicolas</p>