在asp.net(c#)中使用getfocus运行button_click() [英] run button_click() with getfocus in asp.net (c#)

查看:64
本文介绍了在asp.net(c#)中使用getfocus运行button_click()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用asp.net
我在Webform中有很多控制权
我有一个按钮
并且我想在按钮获得焦点时执行功能或过程
示例:当按钮获得焦点或tabindex时,运行button_click()
在asp.net中,我没有getfocus事件或setfocus事件.
我该怎么做

i am working with asp.net
i have many control in a webform
i have a button
and i want execute a function or a procedure when my button get focus
example :when button get focus or tabindex run button_click()
in asp.net i dont have getfocus event or setfocus event.
how i do it

推荐答案

您可以使用javascript来做到这一点,例如


You can do this using javascript, something like this


document.getElementById('txt').focus();
document.getElementById('txt').value= "RoseIndia";


对于Button,我认为没有Focus事件.仅存在Click事件.
您可以尝试使用Click事件,对吗?
For Button I don''t think there is Focus event. Only Click event is present.
You can try with Click event, right?


您可以尝试这样做,以检查TextBox失去焦点时检查用户名的可用性.

http://www.aspdotnet-suresh.com/2011/03/how-to-check-username-availability.html [ ^ ]

http://riderdesign.com/articles/Check-username-availability-with- ASP.NET-AJAX.aspx [ ^ ]
You may try this for Check username availability on TextBox lost focus.

http://www.aspdotnet-suresh.com/2011/03/how-to-check-username-availability.html[^]

http://riderdesign.com/articles/Check-username-availability-with-ASP.NET-AJAX.aspx[^]


这篇关于在asp.net(c#)中使用getfocus运行button_click()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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