如何在ASP.NET TextBox OnTextChanged事件中调用Java Script函数 [英] How to call Java Script function in ASP.NET TextBox OnTextChanged Event

查看:91
本文介绍了如何在ASP.NET TextBox OnTextChanged事件中调用Java Script函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

海,
我有两个名为txtDOB(出生日期)和txtDOJ(加入日期)的文本框
我必须比较两个文本框DOJ不大于DOB..
为此,我编写了一个Java脚本函数,我的问题是如何计算
txtDoJ的"OnTextChanged事件"中的Java脚本函数,

如果你知道帮我..

谢谢和问候,
亲爱的.

Hai,
I have two text boxes named txtDOB (Date Of Birth), and txtDOJ (Date of Join)
i have to compare both text boxes DOJ is not greater than DOB..
For this i wrote a java script function, my problem is how to cal that
java script function in txtDoJ''s "OnTextChanged Event ",

If u know help me..

Thanks and Regards,
Honey.

推荐答案

为此,我编写了一个Java脚本函数,我的问题是如何计算该函数
txtDoJ的"OnTextChanged事件"中的Java脚本函数,


您需要从服务器端添加属性.
试试:
For this i wrote a java script function, my problem is how to cal that
java script function in txtDoJ''s "OnTextChanged Event ",


You need to add an attribute of client side onchange from server side.
Try:
txtDOJ.Attributes.Add("onchange","javascript:MyJSMethodWhereINeedToChange()");



这样做会引入文本更改的客户端事件.



或者,您可以使用 HTML输入控件.这样,直接在html设计器中使用onchange会触发JS事件.为了触发服务器textchange事件,您需要使用onserverchange事件.



Doing this would introduce the client side event of text change.

OR

Alternatively, you can use the HTML input control. In that, directly onchange in html designer would trigger the JS event. In order to trigger server textchange event, you would need to use onserverchange event.


在onchange事件上调用JavaScript.
Call your javascript on onchange event.
<asp:TextBox ID="txtDOJ" runat="server" onchange="javascript:alert(''test'');"></asp:TextBox>


如果要比较两个具有日期时间值的文本框,我建议您使用Type ="Date"
If you want to compare two text boxes having date time values, I would recommend you should use a compare validator with Type="Date"


的比较验证器.


这篇关于如何在ASP.NET TextBox OnTextChanged事件中调用Java Script函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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