ASP.NET 回车提交网页

protected void Page_Load(object sender, EventArgs e)        

{            

TextBox1.Focus();            

//回车提交            

TextBox1.Attributes.Add("onkeydown", @"if(event.which || event.keyCode)

                                                     {

                                                         if ((event.which == 13) || (event.keyCode == 13))

                                                             {

                                                                 document.getElementById('"+

    Button1.UniqueID +

    @"').click();

                                                                 return false;

                                                             }

                                                     }

                                                     else

                                                     {

                                                         return true;

                                                     }; "

                                    );

}

你可能感兴趣的:(asp.net)