用javascript获取子元素 [英] javascript to get child elemet

查看:82
本文介绍了用javascript获取子元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我有一个包含4个向导步骤的向导控件,在这些向导步骤中有一些文本框,我无法使用javascript获取这些文本框的ID.

有任何建议.

Hello,

I have a Wizard Control which has 4 wizardsteps i have some textboxes in those wizardstep i am not able to get the ids of those textbox using javascript.

Any suggestion.

推荐答案



您应该使用控件ClientIdMode ="Static",以便可以通过使用document.getElementById()
来调用这些控件.
关于
Hi,

You should use for the control ClientIdMode = "Static" so you can call those controls by using document.getElementById()

Regards


如果您使用的是ASP.NET 4,请参阅答案一.否则,您必须从控件获取到JS的ClientId.
If you are using ASP.NET 4 see answer one. Otherwise you have to obtain ClientId from control to JS.
document.getElementById('<%=control.ClientId%>');


由于将HTML,JS和C#混合使用,效果不是很好.如果您可以迁移到从未使用过的ASP版本,则仅为此迁移就可以节省维护代码的麻烦.


Not very nice since mixing HTML, JS and C#. If you could migrate to never version of ASP, migrate just for this it will save you some pain in maintaining code.


这篇关于用javascript获取子元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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