Find html control type in javascript

How to find control type in javasccript ?. Say if I have an ASP.NET LinkButton and I want to find the type of control from javascript. How can i do this. I tried using typeof (), but it returns an object to me. and i tried

var control = document.getElementById(Id);//Id is the ClientId of the Linkbutton
alert(control.type);//this is empty.
+3
source share
3 answers

you cannot get control type directly with javascript. you can try using some serveride code to determine the name of the management class:

var cType = '<%= Type.GetType(yourControlServerName).ToString() %>';
alert(cType);
+2
source

You cannot find a control type like in ASP.NET in javascript, I think. There is a tagName attribute that can help you:

control.tagName HTML. ASP, , , .

+3

LinkButton is a type of control on the server side, but on the client side (javascript) there is no LinkButton, but HTML tags processed by this control, which probably contain tags.

So in javascript it makes no sense to talk about LinkButtons.

There may be a better solution for what you are trying to accomplish.

0
source

Source: https://habr.com/ru/post/1758701/


All Articles