aspx文本框的Keypress事件 [英] Keypress event for the aspx textbox
本文介绍了aspx文本框的Keypress事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我没有找到aspx文本框的按键事件,我希望在.cs page.some中帮助我这个事件。
i did''t find the keypress event for the aspx textbox, i want this event in .cs page.some one help me.
推荐答案
代码在.cs文件中运行服务器。如果你想处理客户端代码,按键是,你需要JavaScript。您还可以查看AJAX.NET框架。
The code in a .cs file is ran on the server. If you want to handle client side code, which a key press is, you''ll need JavaScript. You can also look into the AJAX.NET framework.
您可以在JavaScript中使用onkeypress事件。
这是一个示例
You can use the onkeypress Event in JavaScript.
Here is a sample
<asp:textbox id="Textbox1" runat="server" ></asp:textbox>
在KeyPress活动上调用Javascript函数
Javascript function to be called on KeyPress event
function Samplefunction()
{
alert('You have pressed a key inside the textbox');
}
在您的代码隐藏文件中,您可以使用以下行调用javaScript函数。
In your code behind file you can call the javaScript function using the below line.
Textbox1.Attributes.Add("onkeypress", "Samplefunction()");
你在文本框中输入了一些文本,弹出一条警告信息。
有关KeyPress事件的更多信息,请参阅此链接
onkeypress事件 [ ^ ]
希望这有帮助。
When ever you enter some text in the textbox an alert message pops up.
Refer this link for more information on KeyPress event
onkeypress Event[^]
Hope this helps.
这篇关于aspx文本框的Keypress事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文