How to use javascript in .ascx pages

Asad picture Asad · Sep 24, 2010 · Viewed 30.7k times · Source

How to use javascript in .ascx pages

Answer

Oded picture Oded · Sep 24, 2010

You can add script tags to the markup:

<script type="text/javascript">
   // place your javascript here
</script>


<script type="text/javascript" href="path to js file" />

Or use ScriptManager in the code behind so you don't include the same file/js section multiple times if you use multiple controls in a page.

You can find out more about ScriptManager here (overview, including usage scenarios).