Article: AN0001972Updated: 23.09.2018
It is possible to use scripts on pages with webparts. In this way you can easily extend pages with functionality that you require:
- you can add a button to toolbar to start your actions
- you can respond to actions on page
- you can add a new control for displaying more informatio
Scripting is not intended for suppressing ObjectGears system functionality, but for extending by your functions.
Each event can be defined in the script only once. It is not wrong, if some event is not defined at all. For a better script transparency you can create new functions that however cannot collide with event names.
There are following events available for scripts:
Event |
Description |
OnLoad |
Event is triggered after loading a page from the server. It corresponds to ASP.NET event OnLoad. |
OnPreRender |
Event is triggered at rendering the page at the server. It corresponds to ASP.NET event OnPreRender. |
Event description
All the events are defined in the script in the same way. Only with a different function name.
Example of event definition:
function OnPreRender()
{
...
}
Script objects
There are various properties available for various events. These objects are described in the following table.
Control elements
In order to be able use scripts you have to know names of controls, that you can use. The table hereinafter contains list of available names.
Type |
Control code |
Description |
ToolbarButton |
backToolbarButton |
Button Back in the toolbar. |
Passing on objects between webparts and buttons
In certain cases it is necessary to pass on objects between page scripts and button scripts. E.g. for setting where the button should redirect the user after clicking.
In this case you determine necessary information and save it by means of method OG.SetItem (code, object). You will read the value in the script on the button by means of function OG.GetItem (code). Parameter code has to be same for both calls. You can save whatever you want as an object. The values are stored within a single web request. They are dropped then.
Examples
Set up of button Back
You can suppress default behaviour of the button by its set up. You can change the text in the button, its icon, URL (used when clicking on button) and visibility.
Set the properties in the event OnLoad.
function OnLoad()
{
var b = OGForm.GetControl('backToolbarButton');
b.Visible = true;
b.Text = 'Back to start';
b.NavigateUrl = 'Datas.aspx?CId=85';
}