Class PageContentManager
is designed to connect skitov (js) and styles (css) in C# code.
PageContentManager
is a replacement for the deprecated ContextHelper. All new projects should use it.working Principle
The main purpose of PageContentManager
- formation of the list of resources that need to be connected to the current page. The connection is made through IPageContentConnector
(which must be configured in unity).
There are two ways of connecting resources:
- based on filtering HTML (default for reasons of backward compatibility);
- on the basis of the controls-placeholders (recommended);
setup activation script
By analogy with Ohm ContextHelper
‘and his methods ДобавитьСкрипт
and ДобавитьСкриптВDocumentReady
, PageContentManager
‘and have the ability to customize the activation of the script. To this end, the method call to add the script has a flag onPageLoad
the default false
.
Thus, the analog method is ДобавитьСкриптВDocumentReady
call AttachJavaScriptCode(script, true);
Example usage
PageContentManager.AttachJavaScriptCode("alert('Hello');", true); // Displays a message box when the page loads.
Own method of connection of scripts and styles
To use your own method of connection resources, you must create a new class and inherit interface IPageContentConnector
.