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;

                                                     }; "

                                    );

}

posted @ 2011-12-13 09:36  Yao,Mane  阅读(225)  评论(0编辑  收藏  举报