admin管理员组文章数量:1389750
How to find the control type in javasccript?. Say if i have an ASP.NET LinkButton and i wanna find control type from the javascript. How can i do that. I tried using typeof(), but it giving me an object back. and i tried
var control = document.getElementById(Id);//Id is the ClientId of the Linkbutton
alert(control.type);//this is empty.
How to find the control type in javasccript?. Say if i have an ASP.NET LinkButton and i wanna find control type from the javascript. How can i do that. I tried using typeof(), but it giving me an object back. and i tried
var control = document.getElementById(Id);//Id is the ClientId of the Linkbutton
alert(control.type);//this is empty.
Share
Improve this question
asked Aug 9, 2010 at 10:18
niminimi
5,50718 gold badges62 silver badges90 bronze badges
3 Answers
Reset to default 4You can't find the controltype as in ASP.NET in javascript I think. There is the attribute tagName that may help you:
control.tagName returns the HTML tagname. If you really want the ASP control name, you can try to put the controlname in for example the class attribute.
you can't get control type directly by javascript. you can try to use some serverside code to determine control class name:
var cType = '<%= Type.GetType(yourControlServerName).ToString() %>';
alert(cType);
LinkButton is a server side type of control, but in the client side (javascript) there is not a LinkButton but the HTML tags rendered by that control which probably include tags.
So, in the javascript it makes not sense to talk about LinkButtons.
Probably there is a better solution for what you are trying to acplish.
本文标签: aspnetfind the type of html controls in javascriptStack Overflow
版权声明:本文标题:asp.net - find the type of html controls in javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744714940a2621346.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论