文本框的onchange事件未触发。 [英] onchange event for textbox is not firing.

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

问题描述

大家好,



我的网页上有一个文本框,通过代码隐藏我为文本框添加了onchange事件但是在onblur事件工作时它没有工作....我将事件onchange更改为onkeypress和ontextchanged但是没有工作,下面的代码是我正在使用的..我的代码有什么问题,如果有人知道请帮助我..





Hi everybody here,

I have a textbox in my web page and through codebehind i added onchange event for the textbox but it is not working while onblur event working.... i changed the event onchange to onkeypress and ontextchanged but none is working the code below is the one i am using.. what is wrong in my code , if somebody knows pls help me..


Dim ctrlSelect As TextBox = CType(l.FindControl("txtSelect"), TextBox)
        If Not ctrlSelect Is Nothing Then
            ctrlSelect.AutoPostBack = True
            ctrlSelect.Attributes("onblur") &= "Updatedata('" & drItem("PATIENT_NOTE_CONTROL_ID") & "', '1');"
            ctrlSelect.Attributes("ontextchanged") &= "Updatedata('" & drItem("PATIENT_NOTE_CONTROL_ID") & "', '1');"
        End If



<


<

推荐答案

您正在为客户端事件分配处理程序... onblur 适用于您,因为这是一个真实的事件,但是没有这样的客户端事件 ontextchanged ...

有两种选择:

1.您希望客户端事件发生变化 - 它被调用 onchange ...

2.您想使用服务器端 OnTextChanged 事件,在这种情况下,您可以很长时间了解ASP.NET Web技术以及事件在其中的工作方式......
You are assigning even handlers to client-side events...onblur works for you because this is a real event, however no such client side event as ontextchanged...
There are two options:
1. You want client side event for change - it called onchange...
2. You want to use the server side OnTextChanged event, in which case you have a long way to learn about ASP.NET web technology and how events are working within it...


处理时网页开发你需要记住,涉及两台计算机。托管网站的服务器和用户的计算机。如果您希望在文本框的值更改时执行代码,则它与Windows窗体上的操作不同。如果确实如此,那么每次用户按下文本框中的键时,一切都将在数据发送到服务器时停止,textchanged事件代码将运行,然后数据将被发送回用户并重新加载整个页面等不酷。



这就是为什么你可能想要在用户计算机上运行的javascript中做,而不必向服务器发送数据。基本上,javascript中没有textchanged事件。你得到 OnBlur [ ^ ]这基本上是一个失焦的事件。



从技术上讲,有一个TextChanged事件一个网络的文本框,但是如果文本框值在回发之间发生了变化,我的代码才会被点击...而且,每次用户按下文本框中的某个键时,您都不希望进行回发。



希望这有助于解释。
When dealing with web development you need to remember that there are two computers involved. The server that is hosting the web site and the user's computer. If you are wanting to execute code when a textbox's value changes, it just doesn't work the same as it would on a windows form. If it did, then every time a user presses a key in the textbox everything would stop while the data was sent to the server, the textchanged event code would run and then data would be sent back to the user and reload the entire page, etc. Not cool.

This is why you would likely want to do in javascript which runs on the user's computer and doesn't have to send data to/from the server. Basically, there is no textchanged event in javascript. You get OnBlur[^] which is basically a lose focus event.

Technically there is a TextChanged event for a web's textbox, but I the code only gets hit if a textbox value has changed between postbacks...and again, you don't want to do a postback every time a user presses a key in a textbox.

Hope this helps explain.


这篇关于文本框的onchange事件未触发。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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