Reference External CSS and JS Files
- Last UpdatedNov 15, 2023
- 1 minute read
Reference external CSS and JS files dynamically by adding those files in the RuntimeCSS and RuntimeJS collections while returning the GetControlHTML() function to render custom controls in the Forms Designer page and at run-time of the forms.
Example
private void addJsCssFiles()
{
//// <link rel="stylesheet" href="css/jquery-ui.css" />
//// <script src="js/jquery-ui.js" type="text/javascript"></script>
//// <script src="js/knockout-jquery-ui-widget.js" type="text/javascript"></script>
//// <script src="js/autocomplete-datasource.js" type="text/javascript"></script>
if (string.IsNullOrEmpty (this.TopLevelForm.RuntimeCss["css1"]))
{
this.TopLevelForm.RuntimeCss.add("css1", "css/jquery-ui.css");
}
if (string.IsNullOrEmpty (this.TopLevelForm.RuntimeJS["js1"]))
{
this.TopLevelForm.RuntimeJS.add("js1", "js/jquery-ui.js");
}
if (string.IsNullOrEmpty (this.TopLevelForm.RuntimeJS["js2"]))
{
this.TopLevelForm.RuntimeJS.add("js2", "js/knockout-jquery-ui-widget.js");
}
if (string.IsNullOrEmpty (this.TopLevelForm.RuntimeJS["js3"]))
{
this.TopLevelForm.RuntimeJS.add("js3", "js/autocomplete-datasource.js");
}
}
Note:
- CSS file should be placed in the <AVEVA Work Tasks Install Path>/Web/BPMUITemplates/Default/NextGenForms/custom/css/ folder.
- JS file should be placed in the <AVEVA Work Tasks Install Path>/Web/BPMUITemplates/Default/NextGenForms/custom/js folder.