asp文本框双击 [英] asp textbox double click
本文介绍了asp文本框双击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< script 类型 = text / javascript >
function onTxtDoubleClick(){
var x = document.getElementById( <% = Button1.ClientID %> );
if(x)x.click();否则警告(x); }
< / script >
总是返回null。请帮我吗?
我在我的usercontrol上使用这个脚本,用户控件包括texbox和Button1。当我将此usercontrol添加到我的页面时,会出现问题,因为document.getElementById(<%= Button1.ClientID%>); retuns null因为Button,Button1,dosent存在于page.Button1存在于usercontrol中
解决方案
你试试这个吗?
document.getElementById(' buttonName')
< html < span class =code-attribute> xmlns = http://www.w3.org/1999/xhtml >
< head runat = server >
&l t; script type = text / javascript >
function TextBoxDoubleClick(){
alert( 双击检测到。);
}
< / 脚本 >
< / head >
< body >
< 表单 id = form1 runat = server >
< div>
< asp:textbox id = TextBox1 ondblclick = TextBoxDoubleClick() runat = server > < / asp:textbox >
< / div > ;
< /表格 >
< / body >
< / html >
< script type = text / javascript>
function onTxtDoubleClick(){
var x = document .getElementById( buttonclientid);
if (x)x.click(); else alert(x); }
< / script>
对你有用
问候.... :)
<script type="text/javascript">
function onTxtDoubleClick() {
var x = document.getElementById("<%= Button1.ClientID %>");
if (x) x.click(); else alert(x); }
</script>
Always return null .Please Hep me?
I am using this script on my usercontrol and the user control includes texbox and Button1. When I am adding this usercontrol in to my pages then problem occurs because document.getElementById("<%= Button1.ClientID %>"); retuns null because the Button ,Button1, dosent Exist in the page.Button1 exist in usercontrol
解决方案
Do you try this?
document.getElementById('buttonName')
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <script type="text/javascript"> function TextBoxDoubleClick() { alert("Double click detected."); } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:textbox id="TextBox1" ondblclick="TextBoxDoubleClick()" runat="server"></asp:textbox> </div> </form> </body> </html>
<script type="text/javascript"> function onTxtDoubleClick() { var x = document.getElementById("buttonclientid"); if (x) x.click(); else alert(x); } </script>
will work for you
regards....:)
这篇关于asp文本框双击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文