document.getElementById(按钮... [英] document.getElementById ( button ...
问题描述
我有一个文本框和TextboxdoubleClick调用脚本函数
I have a textbox And TextboxdoubleClick Call script function
txtBox.Attributes.Add("Ondblclick", "return clickButton(event, '" + btnSearch.ClientID + "')");
我使用以下脚本在我的usercontrol中调用按钮单击。但 document.getElementById(buttonid)
返回undefined
I am using the below script to call a button click in my usercontrol. But document.getElementById(buttonid)
returns undefined
<script type="text/javascript">
function clickButton(event, buttonid) {
var bt = document.getElementById(buttonid);
if (bt) {
bt.click();
}
}
推荐答案
建议
放下如下调试器......
Suggestion
Put a debugger like below...
<script type="text/javascript">
function clickButton(event, buttonid) {
debugger;
var bt = document.getElementById(buttonid);
if (bt) {
bt.click();
}
}
现在,当您双击 TextBox $ c时,执行将在此时中断$ c>。
in
然后,在此时检查 buttonid
的值,方法是将鼠标悬停在其上或将其置于<$ c $的监视之下c> FireBug FireFox
。
同时检查是否有任何元素(带有 buttonid
)是否存在于呈现的html中。
Now, the execution will break at that point when you double click on TextBox
.
Then, check the value of buttonid
at this point by either hovering on it or putting it in watch of FireBug
in FireFox
.
Also check whether there is any element (with buttonid
) present in the rendered html or not.
你好,
请试试这个,
使用 btnSearch.StaticID 代替 btnSearch.ClientID
Hello,
Please try this,
Use btnSearch.StaticID instead of btnSearch.ClientID
txtBox.Attributes.Add("Ondblclick", "return clickButton(event, '" + btnSearch.StaticID + "')");
这篇关于document.getElementById(按钮...的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!