asp.net中的用户控件为子控件添加前缀字符串,导致在javascript中引用它们时出现问题 [英] user controls in asp.net prefixing string to child controls causing problem to refer them in javascript

查看:67
本文介绍了asp.net中的用户控件为子控件添加前缀字符串,导致在javascript中引用它们时出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用户控件,其中没有文本框,我正在使用AJAX动态填充子控件,但是asp.net在子控件中附加了一些字符串,导致编写JavaScript代码时出现问题。
尽管我尝试过getElementLike('key')来迭代元素并为我找到合适的元素,但这确实效率不高。因此,如果有人对此问题有任何见解,请为您提供意见/建议。

谢谢

I have user control in which there are text boxes no i am using the AJAX to populate the child controls dynamically however asp.net appending some string to child controls causing problems to write the JavaScript code.
Though i have tried getElementLike('key') which iterate elements and get the right one for me but this is really inefficient. So if anybody has any insight on this issue please provide you input/suggestions.
Thanks all,

推荐答案

看看使用 someControl.ClientId ,它将为您提供ASP.NET生成的控件ID。使用此ID,您将能够通过javascript正确定位元素。

Look at using someControl.ClientId, which will give you the ASP.NET generated id of the control. Using this Id you will be able to correctly target the element via javascript.

这篇关于asp.net中的用户控件为子控件添加前缀字符串,导致在javascript中引用它们时出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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