添加JavaScript到ASP.NET文本框控件的属性的onblur [英] Adding javascript to the OnBlur property of an ASP.NET text box control

查看:325
本文介绍了添加JavaScript到ASP.NET文本框控件的属性的onblur的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有指定一些JavaScript来对一个ASP.NET文本框的onblur事件执行的方法吗?在我看来,就像如果我添加任何事件处理程序到TextBox对象,他们将只是导致回发到做我想要什么的服务器isntead。基本上,我只是希望能够有文本框在这个HTML渲染:

Is there a way to specify some JavaScript to execute on the OnBlur event of an ASP.NET text box? It seems to me like if I add any event handlers to the TextBox object they will just cause postbacks to the server isntead of doing what I want. Basically, I just want to be able to have the textbox be rendered in this HTML:

<INPUT type="text" onblur="alert('1234')" />

谢谢!

推荐答案

也可以去:

<asp:TextBox runat="server" onblur="Javascript:alert('1234');" />

如果你不觉得像在codebehind设置它。

if you dont feel like setting it up in the codebehind.

即时猜测为什么你最终回传,一定是因为你设置的AutoPostBack的文本框为true。这使得文本回传客户端onchange事件被触发时。切换到错误的,它将作为一个正常输入元件

Im guessing the reason why you end up with postbacks, must be because you have set AutoPostBack on the textbox to true. That makes the textbox postback when the client-side onchange event is triggered. Switch it to false, and it will act as a normal input-element.

这篇关于添加JavaScript到ASP.NET文本框控件的属性的onblur的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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