<p>I have an ASP.NET web page with a Login control on it.  When I hit Enter, the Login button doesn't fire; instead the page submits, doing nothing.</p>

<p>The standard solution to this that I've found online is to enclose the Login control in a Panel, then set the Panel default button.  But apparently that doesn't work so well if the page has a master page.  I've tried setting the default button in code with <em>control</em>.ID, <em>control</em>.ClientID, and <em>control</em>.UniqueID, and in each case I get:</p>

<blockquote>
  <p>The DefaultButton of panelName must be the ID of a control of type IButtonControl.</p>
</blockquote>

<p>I'm sure there's a way to do this with JavaScript, but I'd really like to do it with plain old C# code if possible.  Is it possible?</p>

you have to add something like this in page load...
```
```
txtPassword.Attributes.Add("onKeyPress", "javascript:if (event.keyCode == 13) __doPostBack('" + lnkSubmit.UniqueID + "','')")
```
```
the password textbox has an onKeyPress attribute added that will force a doPostBack on the submit button if the "Enter" key is pressed. This simulates clicking the submit button.