Monday, April 25, 2011

Check whether a HTML control exists or not


<!DOCTYPE html>
<html> 
<head> 
   <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
   <title>Check whether a control exists</title> 
</head> 
<body> 
   <script type="text/javascript">
       function check() {
           if (document.getElementById('btn_yasser')) {
               alert('Exists !');
           }
           else {
               alert('Not present');
           }
       }
   </script> 
   <input type="button" id="btn_yasser" value="click me" onClick="check();" /> 
</body> 
</html>
The same could be used for ASP controls.
Hope this helps.

0 comments:

Post a Comment

 

2011 ·Code-Studio by yrus.