<ScriptBlock>

The ScriptBlock tag is used to inject HTML<script> tags into one of several different locations in the page. Typically this is used to insert Javascript functions and/or libraries into the page. You can also insert <style> tags into the page using this tag.

Syntax

<ScriptBlock
    ScriptId="string"
    BlockType="HeadScript|ClientScript|StartupScript|ClientScriptInclude"
    RegisterOnce="True|False"
    Url="url">
    
    <script type="text/javascript" ...>
      ...Javascript...
    </script>
    
</ScriptBlock>

Remarks

Back to top

Example

<AddForm>
<ScriptBlock ScriptId="AlertScripts" RegisterOnce="true">
  <script type="text/javascript">
    function helloWorld(){
      alert('Hello World');
    }
    function goodbyeWorld(){
      alert('Goodbye Cruel World');
    }
    function showMessage(sMessage){
      alert(sMessage);
    }
  </script>
</ScriptBlock>
  <table width="100%">
    <tr>
      <td width="250" valign="top">
        
        <!-- SCRIPT BLOCK EXAMPLE -->
        <a href="#" onclick="helloWorld();">Hello World</a><br />
        <a href="#" onclick="goodbyeWorld();">Goodbye</a><br />
        <a href="#" onclick="showMessage('Hello and Goodbye')">Show Message</a>
      

      </td>
    </tr>
  </table>
</AddForm>
 
 
Back to top