Defining the script element
Use the <script> element to define a client-side script. The element can contain either scripting statements or point to an external script file through the src attribute.
script element is defined in the Content Manager metadata configuration as:
<script language = "language-name"> </script>
- The language attribute is mandatory. Its value is the code language of the embedded code block.
- The language is mapped to the appropriate CodeDOM compiler.
- Languages supported are Visual Basic and CSharp.
- The supported languages can also be found in the metadataconfig.xsd.
- The language name is not case-sensitive.
- The Content Manager metadata configuration only supports .NET framework scripts, assuming the appropriate provider is installed on the machine and is registered in the system.codedom section of the machine.config file.
script element, it is strongly recommend that the script, regardless of the language, be placed inside a CDATA section. Because the script can contain operators, identifiers, or delimiters for a given language, if it is not contained within a CDATA section, it has the potential of being misinterpreted as XML. The following XML shows a template of the CDATA section where code can be placed.
<script language='CSharp'>
<![CDATA[
// Code block.
]]>
</script>
Two parent elements and two child elements are defined. The number of occurrences is unlimited.
Parent Elements
- <ishfrm>
Attributes Event Load Load the form Closing Close the form Validating Validate the form <ishfrm id="Properties_Update_ISHMasterDoc" load="Form_Load" closing="Form_Closing" validating ="Form_Validating"> - <ishfrmfield>
Attributes Event Load Load the field Enter Enter the field Leave Leave the field Valuechanged Change the value of the field Validating Validate the field <ishfrmfield id name="TitleField" ishfieldref="FTITLE" level="logical" enter="Field_Enter" valuechanged="Field_ValueChanged" leave ="Field_Leave" load="Field_Load" validating="Field_Validating">
Child Elements
- <assembly> element that can be used to define assemblies
- <using> element that can be used to define namespaces
Within the script element you can declare variables and define functions. When a function is defined, it is contained in a script block. Metadata config files can contain multiple script blocks, each operating independent of the other. That means that if you are executing inside a script block, you cannot call a function that you defined in another script block. Because each script block can be in its own language, and the block is parsed according to the grammar rules of that language parser we recommend that you use the correct syntax for the language in use. For example, if you are in a Microsoft C# script block, use the C# comment syntax.