我的窗体中没有用到Form,所用到的控件全部是服务器端控件,含有很多TextBox和Button,可是所有的TextBox按下回车都响应同一个按钮,很烦人,如何分别为每一个TextBox指定一个相应它的按钮呢?希望哥哥们帮忙啊...
写JavaScript脚本控制!
HTML:
function SubmitKeyClick(button)
{
if (event.keyCode == 13)
{
event.cancelBubble = true;
event.returnValue = false;
button.click();
}
}
<asp:TextBox id="TextBox1" onkeypress="SubmitKeyClid(Button1)" runat="server"/>
或者在CS中调用:
TextBox1.Attributes.Add("onkeypress","SubmitKeyClick(Button1)");