如何在按Tab键上获取值 [英] How do I fetch the value on pressing tab key

查看:94
本文介绍了如何在按Tab键上获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好...



我有7个文本框。



前6个用于输入乘法的数字。

第三个用于显示乘法的结果。



我希望乘法的结果出现在第7位文本框一旦我输入

6个文本框中的数字,而不按任何按钮。我在第6个文本框中使用了textchanged event。

所以结果只出现在我在第6个文本框中更改/输入值..

但是按Tab键键必须得到结果...

请在c#和html中发送语法....

有没有人知道怎么做而不使用javascript?



我尝试过:



我在第6个文本框中使用了textchanged event。 
所以只有当我在第6个文本框中更改/输入值时结果才会出现..
但是必须按Tab键才能得到结果......

解决方案

看看在Javascript onblur活动 [ ^ ] - 当用户离开文本框并保存往返服务器进行验证/计算。



没有C#事件来检测用户进入或离开文本框:文本框事件(System.Web.UI.WebControls) [ ^ ]但是你可以使用Javascript事件触发C#,如果你真的,真的必须在服务器的C#中执行此操作。


检查这个小提琴

JSFiddle [ ^ ]

< pre lang =HTML> < script src = https://ajax.googleapis .com / ajax / libs / jquery / 3.1.1 / jquery.min.js > < ; / script >
< script >


function (){


Hello...

I have 7 textboxes .

The first 6 are for entering numbers for multiplication.
And the third is for displaying the result of multiplication.

I want the result of multiplication to appear in the 7th textbox as soon as I enter
the numbers in the 6 textboxes, without pressing any buttons .I used "textchanged event" on 6th textbox.
So the result comes only when i change/enter the value in 6th textbox..
but result has to come by pressing the tab key...
Please send me syntax , both in c# and html....
Does anyone know how to do this without using javascript?

What I have tried:

I used "textchanged event" on 6th textbox.
So the result comes only when i change/enter the value in 6th textbox..
but result has to come by pressing the tab key...

解决方案

Look at doing it in the Javascript onblur Event[^] - it occurs when the user leaves the textbox, and saves a round trip to the server to do the valiudation / calculation.

There is no C# event to detect the user entering or leaving a textbox: TextBox Events (System.Web.UI.WebControls)[^] but you could use the Javascript event to trigger the C# if you really, really must do this in C# at the server.


check this fiddle
JSFiddle[^]

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script>


(function () {


这篇关于如何在按Tab键上获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆