今天碰到个问题,首页是好几个用户控件组成,上面有搜索按钮,下面有登陆按钮,客户想输完密码回车直接登陆,现在成了搜索,网上找了好多方法都不行,后来看到原来ASP.NET 2.0中有个defaultbutton属性,具体也不介绍了,用法如下
<
form
id
="Form1"
defaultbutton
="loginButton"
defaultfocus
="TextBox1"
runat
="server"
>
现在又有个问题如何获取用户控件上的Button的ID,一个同事介绍的好方法,直接浏览页面,右键源代码找到ID为left_login1$Button1,
最后我在后台这样使用
protected
void
Page_Load(
object
sender, EventArgs e)
... {
form1.DefaultButton = "left_login1$Button1";
}
... {
form1.DefaultButton = "left_login1$Button1";
}