没有Javascript的TextBox OnClick事件 [英] TextBox OnClick event without Javascript

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

问题描述

我有一个文本框,我希望它在点击时被触发.我读了一些我用 LinkBut​​ton 包装的论坛.这是我的样机 UI 部分:

I have a textbox which I want it to be fired on Click. I read some forum in which I wrapped in LinkButton. Here is my mockup UI part:

 <asp:LinkButton runat = "server" OnClick = "txtAgentName_TextChanged"><asp:TextBox ID="txtAgentName" runat="server"></asp:TextBox></asp:LinkButton>

这是我背后的代码:

  protected virtual void txtAgentName_TextChanged(object sender, EventArgs e)
    {

    }

而且它似乎没有启动!我不想使用 Javascript :-P

And it seems like it is not firing up! I dont want to use Javascript :-P

推荐答案

asp 文本框控件没有服务器端单击事件.OnClick"为文本框呈现一个 htmlOnClick"属性.您的代码将导致 JavaScript 错误.

the asp textbox control does not have a server side click event. "OnClick" renders an html "OnClick" attribute for the textbox. Your code will result in a javascript error.

您最好的选择是在触发文本框模糊事件时对 WebMethod 进行 ajax 调用,并根据结果对文本框执行某些操作.这篇文章将帮助您进行 webmethod 调用.使用 jquery,您可以非常轻松地处理模糊事件.

your best bet is to do an ajax call to a WebMethod when the textbox blur event is fired and do something to the textbox based on the result. this article will help you with the webmethod call. using jquery you can handle the blur event pretty easily.

这篇关于没有Javascript的TextBox OnClick事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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