I'm now writing Dictionary program, based on Web2.0 with Asp.net. In asp.net, we gotta use these asp.net control which support us more performance to SQL and performance. But, to control these are really complicated and it gives serveral times to manage to control.

In our project, there is only one input textbox in welcome page. At first, whenever user type one word in this and press Enter Key, I want to run click even of "search" button. But, whenever I type word and press enter, it cannot run click event of search button. So, I was out of shape of this one day. Today, I keep on searching and then I got it now. Here is solution for this problem.

Coding for welcome.aspx

view plain print about
1<form defaultbutton="button1" runat="server">
2<asp:textbox id="textbox1" runat="server"/>
3<asp:button id="button1" text="Button1" runat="server"/>
4</form>

Coding for welcome.aspx.cs

view plain print about
1TextBox1.Attributes.Add("onkeydown", "if(event.which || event.keyCode){
2    if ((event.which == 13) || (event.keyCode == 13)) {
3        document.getElementById('"+Button1.UniqueID+"').click();
4        return false;
5        }}
6    else {
7        return true
8        };
9    ");

Best Credit to : http://www.beansoftware.com/asp.net-tutorials/accept-enter-key.aspx