C# 按键功能在文本框上不起作用
我有一个web表单项目,其中我想使用按键将数据插入文本框 这是我的aspx文件C# 按键功能在文本框上不起作用,c#,asp.net,webforms,C#,Asp.net,Webforms,我有一个web表单项目,其中我想使用按键将数据插入文本框 这是我的aspx文件 <asp:Textbox runat ="server" id="Scan" style="width:1200px;height:100px;border:1px solid #000; background-color:white"></asp:Textbox> 当我运行程序时..文本框不工作,即使是错误消息。。 我试过了 有人知道如何解决这个问题吗?非常感谢您Winforms!
<asp:Textbox runat ="server" id="Scan" style="width:1200px;height:100px;border:1px solid #000; background-color:white"></asp:Textbox>
当我运行程序时..文本框不工作,即使是错误消息。。
我试过了
有人知道如何解决这个问题吗?非常感谢您Winforms!=网络表单。您尚未为aspx中的文本框分配处理程序。请参阅:。webforms中最接近的是
OnTextChanged
。对于webforms中的大多数“按键”操作,您可能希望使用javascript,这样您就不会在每次按键时都重新加载页面,从而完成完整的请求-响应过程。@JonP谢谢,先生!我意识到我的错误
private void textbox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
string strSql;
string en ;
en = desk;
//if (e.KeyChar == Strings.Chr(13))
if (e.KeyChar == (char)Keys.Enter)
{
string strDeskNo = (Scan.Text);//sepatutnya ada Trim(Scan.Text)
strSql = "Insert into ";// sql statement
if (strDeskNo == "")
{
Scan.Style.Add("color", "red");
Scan.Text = "Please scan again ! ";
msgBoxOpen = true;
MessageBox.Show("There is no desk no entered! Please Scan again.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
msgBoxOpen = false;
Scan.Text = "";
Scan.Style.Add("background-color", "white");
Scan.Focus();
return;
}
e.Handled = true;
}
}