如何在用户控件文本框onblur上调用JavaScript? [英] How to call javascript on usercontrol textbox onblur?

查看:59
本文介绍了如何在用户控件文本框onblur上调用JavaScript?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!
我有一些usercontrol texboxes让我们在页面上说一下DateControl.我想在这些用户控件之一的onblur上调用javascript函数.在该功能中,我想在usercontrol(日期控件文本框)的输入值中增加几天.当我从usercontrol调用javascript时,它不起作用.我的帐户如下;

Hi!
I have some usercontrol texboxes Let us say DateControl on a page. I want to call a javascript function on onblur of one of these usercontrols. In that funcion I want to add some days in the entered value of usercontrol(Date Control Textbox). When i call javascript from usercontrol it doesn''t work. my account is as follows;

<uc1:DateControl ID="DateControlLastExecDate"  runat="server"  önblur="javascript:CaluculateDate();"/>



因此,请plz guide



So plz guide

推荐答案

尝试将JavaScript添加到usercontrol的文本框中,而不是在javascript中不知道datacontrol或usercontrol,因此没有发送"onblur"消息首先(我认为).

提示:将页面加载到IE并执行查看源代码",您将看到控件同时具有服务器ID和客户端ID.您还将很好地了解页面中如何集成用户控件.这样可以使您更好地了解该怎么做.

希望这会有所帮助.
Try adding the javascript to the Textbox on the usercontrol instead a datacontrol or usercontrol is not known in javascript and hence there is no "onblur" message sent in the first place (I think).

Tip: Load your page into IE and do a "view source" you''ll see that your control has both a server id and a client id. you''ll also get a good view on how the user control is integrated in the page. That might give you a better understanding on what to do.

Hope this helps.



  1. 该事件称为 onblur 而不是 önblur .
  2. 您的JavaScript函数是否真的称为CaluculateDate?应该不是更像CalculateDate吗?
  3. 已添加:作为

  1. The event is called onblur and not önblur.
  2. Is your javascript function really called CaluculateDate? Shouldn''t that be more like CalculateDate?
  3. Added: As V.[^] correctly pointed out: You have defined the usercontrol so in order to get the javascript event working you''d have to wire up the onblur event on some HTML part of your control that would suport such an event before it gets rendered.



干杯!

--MRB



Cheers!

--MRB


另一种方法是将javascript函数添加到Text控件的onBlur属性.

范例:

在后面的代码中,您可以这样做

Another way is to add the javascript''s function to the Text control''s onBlur attribute.

Example :

In your code behind, you may do this

<pre lang="cs">protected void Page_Load(object sender, EventArgs e)<br />
       {<br />
           this.txtName.Attributes.Add("onBlur", "return CalculateDate();");<br />
       }</pre><br />



:-)
巴拉吉(Balaji)



:-)
Balaji


这篇关于如何在用户控件文本框onblur上调用JavaScript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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