Ext.Net TextField Enter事件
Posted guopm
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ext.Net TextField Enter事件相关的知识,希望对你有一定的参考价值。
(1)DirectEvents触发后台
<ext:TextField ID="txt_Upc" runat="server" Width="150">
<DirectEvents>
<KeyPress OnEvent="txtUpc_KeyPress">
<ExtraParams>
<ext:Parameter Name="keynum" Value="e.getKey()" Mode="Raw" />
</ExtraParams>
</KeyPress>
</DirectEvents>
</ext:TextField>
CS后台:
protected void txtUpc_KeyPress(object sender, DirectEventArgs e)
{
string key = e.ExtraParams["keynum"].ToString();
if (key == "13")
{
//do
}
}
(2)Listeners触发前台
<ext:TextField ID="txt_Upc" runat="server" Width="150">
<Listeners>
<KeyPress Handler="if (e.getKey()==Ext.EventObject.ENTER){Ext.net.DirectMethods.TextKeyPress();e.stopEvent();}" />
<SpecialKey Handler="txtUpcEnter(e.getKey(),#{txt_Upc}.getValue());" />
</Listeners>
</ext:TextField>
JS:
function txtUpcEnter(keynum, value) {
if (keynum== "13") {
}
}
(3)DirectMethods-触发后台
(个人心得,我在扫描枪扫描控件自动Enter时DirectEvents方法不可用,Listeners触发前台方法可用)
<ext:TextField ID="txt_Upc" runat="server" Width="150">
<Listeners>
<KeyPress Handler="if (e.getKey()==Ext.EventObject.ENTER){Ext.net.DirectMethods.TextKeyPress();e.stopEvent();}" />
<SpecialKey Handler="Ext.net.DirectMethods.txtUpcEnter(e.getKey(),#{txt_Upc}.getValue());" />
</Listeners>
</ext:TextField>
CS后台:
[DirectMethod]
public void txtUpcEnter(string key, string value)
{
//
}
以上是关于Ext.Net TextField Enter事件的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Flutter 测试中模拟 TextField 上的按 ENTER
Jetpack Compose TextField 捕获键盘 Enter-input