Interview Question in Asp.net 2.0


 

Interview Question :: How to use javascript in asp.net 2.0 usercontrol

You can write your Client Script blocks directly in your ASPX page between a <script type = "text/javascript" language = "javascript" > </script> block.

If you are using ASP.NET controls you have to use the Control.ClientID when referring to the control (since it will be rendered as an HTML element)

example:
<script type = "text/javascript" language = "javascript" >
var txtBox = document.getElementById( '<%= txtBox.ClientID %>');
//work with your txtBox variable Now.
</script>

For more info, you can check:
http://aspalliance.com/726
http://quickstart.developerfusion.co.uk/...
http://www.developer.com/net/asp/article...
http://weblogs.asp.net/skoganti/archive/...

Hope this helps.
by ksk