如何更改文本框上的事件 [英] how to perfrom event on textbox changed

查看:84
本文介绍了如何更改文本框上的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本框.我想在文本框上写东西时单击文本框外,然后在该值的基础上执行该操作.哪个事件针对此类问题执行

i have a textbox. i want when i have write something on textbox and when i click outside the textbox then on the basics of that value the action must be performed. which event perform on this type of problem

推荐答案

您可以使用文本框的textchanged事件或Onblur事件.
You can use textchanged event or Onblur event of the textbox .


阿文德,

如果要在客户端执行操作(即javascript),则可以使用onblur event.

Hi Arvind,

If you want to perform the action on client side ( ie: javascript ) you can use onblur event.

<asp:TextBox ID="txt" runat="server" onblur="javascript:dosomething()"></asp:TextBox>





var dosomething = function () {
    alert('you have lost the focus');
}




在服务器端,您可以使用TextChanged 事件,
不要忘记放 AutoPostBack = true




in server side, you can use TextChanged event,
Dont forget to put AutoPostBack=true

<asp:TextBox ID="txt" runat="server" AutoPostBack="true" OnTextChanged="txt_TextChangedEvent"></asp:TextBox>





protected void txt_TextChangedEvent(object sender, EventArgs e)
       {

       }


这篇关于如何更改文本框上的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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