我想在文本框中触发服务器端事件,请输入asp.net
<asp:TextBox ID="TextBox1" runat="server" onkeypress="Button2_Click"></asp:TextBox>
<asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Send" />
获取错误:http://localhost:61421/Default.aspx中第31行第87列的未处理异常 0x800a1391-JavaScript运行时错误:“ Button2_Click”未定义
答案 0 :(得分:0)
我找到了答案,以下代码对我有用:“将我的代码放在属性为“ DefaultButton”的面板下”
还有我的toltal编码
<asp:Panel runat="server" DefaultButton="Button2_Click">
<asp:TextBox ID="TextBox1" runat="server" onkeypress="Button2_Click"></asp:TextBox>
<asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Send" />
</asp:Panel>
谢谢你的爵士乐