Quick overview
1. General information
- JavaScript is program code executed on the client side in a web browser.
- JavaScript code can be executed:
- from the “JavaScript” control in an edit form,
- from the “JavaScript” control on a view page,
- after clicking a button placed in an edit form,
- after clicking a button placed on a view page,
- when JavaScript events of database controls in an edit form are triggered (“OnBlur”, “OnChange”, “OnClick”, “OnFocus”).
- The following types of variables and calls can be used in JavaScript:
- NET Genium text variables – for example “#today#”,
- text variables that reference database control objects in the HTML document object model of an edit form via identifiers – “#ng_#”,
- text variables that reference values entered by the user in an edit form via identifiers – “#ng_:value#”,
- text variables that reference the current values stored in the database via identifiers – “#ng_:history#”,
- extended text variables that reference the table containing a database control in an edit form – “#ng_:Table#”.
- Database controls in an edit form are arranged vertically and are technically placed inside HTML tables (<table>…</table>).
- Each database control is placed in its own table, whose visibility can be modified (for example #ng_:Table#.style.display = 'none';).
- extended text variables that reference the label of a database control in an edit form – “#ng_:Name#”.
- Labels of database controls are displayed to the left of the control itself and are implemented using HTML <label>…</label> elements.
- Each database control has its own label whose displayed text can be changed using JavaScript (for example #ng_:Name#.innerHTML = 'abc';).
- calls to NET Genium JavaScript functions – for example “control_Enable(#ng_#);”,
- calls to NET Genium server functions – for example “SQL(SELECT …)” or “SQLARRAY(SELECT …)”,
- calls to external functions written in C# – for example “ngef(MyFirstFunction, #today#)”.
- In the NET Genium environment, JavaScript is most commonly used for:
- reading and setting values of database controls,
- validating values entered by the user,
- changing properties and behavior of database controls,
- hiding or showing parts of an edit form,
- loading or saving data using AJAX requests.
2. Variables
- nID – ID of the currently open record in the edit form (it is not recommended to use #id#)
- sID – text representation of nID (string)
- Page_IsPostBack – The page is loaded after a postback
- dateSeparator – Date separator (usually “.”)
- numberSeparator – Decimal separator (usually "","")
- domLib_isIE – The current browser is Internet Explorer
- domLib_isIE56 – The current browser is Internet Explorer version 5 or 6
- domLib_isIE7 – The current browser is Internet Explorer version 7
- domLib_isIE8 – The current browser is Internet Explorer version 8
- domLib_isIE9 – The current browser is Internet Explorer version 9
- domLib_isIE56789 – The current browser is Internet Explorer version 5, 6, 7, 8 or 9
- domLib_isIE10 – The current browser is Internet Explorer version 10
- domLib_isIE11 – The current browser is Internet Explorer version 11
- domLib_isChrome – The current browser is Google Chrome, Microsoft Edge, or Opera version 15 and above
- domLib_isFirefox – The current browser is Mozilla Firefox
- domLib_isSafari – The current browser is Safari
- domLib_isOpera – The current browser is Opera version 12.15 or lower
- domLib_isMobileDevice – The current browser is a mobile device
- domLib_isCE – The current Windows CE device browser
3. Functions
void _loadUrl(object o, string url)
The function loads the page defined by the ""url"" parameter using an asynchronous ajax call. The function does not wait for a response from the server; after calling it, the execution of javascript code continues. The “o” parameter is an auxiliary object (guard) used to prevent parallel calls on the same object – if a response has not yet been received, a new call is skipped. For parallel calls, use “new Object()” as the “o” parameter.
Example:
var p0 = 'ěščřžýáíé', p1 = 'ĚŠČŘŽÝÁÍÉ';
_loadUrl(new Object(), 'ngef.aspx?MyFirstFunction,' + urlEncode(p0) + ',' + urlEncode(p1));
void _loadUrl(object o, string url, string/function f)
Same as the previous variant, but after receiving the response it calls the callback “f”. The resulting HTML code of the page is passed to the “f” function as the first parameter. The “f” parameter can be a function name (string) or a direct function reference.
Example:
function ajaxTest()
{
var p0 = 'ěščřžýáíé', p1 = 'ĚŠČŘŽÝÁÍÉ';
_loadUrl(new Object(), 'ngef.aspx?MyFirstFunction,' + urlEncode(p0) + ',' + urlEncode(p1), ajaxResponse);
}
function ajaxResponse(html)
{
alert(html);
}
for (var i = 0; i < 5; i++)
{
ajaxTest();
}
void _loadUrl(object o, string url, string/function f, string id)
Same as the previous variant. The optional parameter “id” is passed to the “f” function as the second parameter.
Example:
function ajaxTest(id)
{
var p0 = 'ěščřžýáíé', p1 = 'ĚŠČŘŽÝÁÍÉ';
_loadUrl(new Object(), 'ngef.aspx?MyFirstFunction,' + urlEncode(p0) + ',' + urlEncode(p1), ajaxResponse, id);
}
function ajaxResponse(html, id)
{
alert(id + ': ' + html);
}
for (var i = 0; i < 5; i++)
{
ajaxTest(i);
}
void _loadUrl(object o, string url, string/function f, string id, string params)
Same as the previous variant. The “params” parameter is sent using the POST method (format: key=value&key2=value2). If “params” is non-empty, POST is used; otherwise GET.
Example:
function ajaxTest(id)
{
var p0 = 'ěščřžýáíé', p1 = 'ĚŠČŘŽÝÁÍÉ';
_loadUrl(new Object(), 'ngef.aspx?MyFirstFunction', ajaxResponse, id, 'p0=' + urlEncode(p0) + '&p1=' + urlEncode(p1));
}
function ajaxResponse(html, id)
{
alert(id + ': ' + html);
}
for (var i = 0; i < 5; i++)
{
ajaxTest(i);
}
void _loadUrl(object o, string url, string/function f, string id, string params, string errorMessage)
An extension of the previous variant with the “errorMessage” parameter. If the server returns an HTTP status other than 200, an alert with the text “errorMessage” is displayed to the user.
Example:
_loadUrl(new Object(), 'ngef.aspx?MyFunction', ajaxResponse, null, null, 'Error loading data.');
void alert2(string value)
The function displays a native browser alert with the text specified by the “value” parameter. Before displaying, it removes HTML tags and replaces “ ” entities with a space. It also resets the internal guard flags “_form_Update” and “_bt_Click” so that deferred operations (e.g. picker) can be performed after the alert is closed.
Example:
alert2('Record saved successfully.');
alert2('<b>Warning:</b> Value must not be empty.');
void alert3(string value)
The function displays a native browser alert with the text specified by the “value” parameter without any content modification (HTML tags are not removed). It also resets the internal guard flags in the same way as “alert2”.
Example:
alert3('Value: <b>' + value + '</b>');
void attachEvent2(object o, string type, function listener)
The function appends the “listener” function to the “o” object event. “Type” defines the type of event, e.g. load, scroll, etc. Internally uses addEventListener (modern browsers) or attachEvent (older IE).
Example:
attachEvent2(window, 'load', function () { alert('onload1'); });
attachEvent2(window, 'load', test);
function test()
{
alert('onload2');
}
void bt_Click()
The function invokes the form reload (postback) by clicking the btUpdate button. During this event, the data of all tables, calendars, graphs, etc. will be reloaded. This function has been replaced by the “form_Update” function.
Example:
bt_Click();
void bt_Click(string id)
The function triggers a programmatic click on the button specified by the “id” parameter. The function first tries to find an element with the given ID, and if it cannot find it, with the given text. Internally uses the guard “_bt_Click” to prevent double-clicking.
Example:
bt_Click(BT123);
bt_Click('Save');
void bt_Click(string id, string name, string value)
An extension of the previous variant. Before clicking the button, it inserts a hidden field with the name “name” and value “value” into the form. Allows an additional parameter to be passed during a postback.
Example:
bt_Click(BT123, 'action', 'delete');
bool bt_Eval(object bt, string url, string/function f)
When the button is pressed, the function loads the page defined by the “url” parameter using AJAX and uses the validating function “f” to verify the loaded HTML code. On the first call (AJAX in progress) it returns “false” and prevents the default button action. When the response arrives, it calls “f” with the result – if “f” returns “true”, the button is clicked again and the action proceeds. The “f” parameter can be a function name or a direct reference. The “f” function receives (html, url) as parameters.
Example:
1st variant:
return bt_Eval(this, 'ngef.aspx?test', 'evalFunction');
2nd variant
return bt_Eval(this, 'ngef.aspx?test', ajaxResponse);
function ajaxResponse(html)
{
return confirm('Response: ' + html);
}
3rd variant
return test(this);
function test(bt)
{
if (!bt_Eval(bt, 'ngef.aspx?test', ajaxResponse)) return false;
return confirm('Continue?');
}
function ajaxResponse(html)
{
return confirm('Response: ' + html);
}
object bt_FindByText(string text, int index)
The function returns a button with the title specified by the “text” parameter. The “index” parameter is optional and specifies which occurrence of the button with the title “text” the function should return. Numbering starts from zero.
Example:
var bt = bt_FindByText('Today', 2); // Returns the object of the third button named “Today”
bool bt_Icon(object bt, string url)
The function sets the image defined by the “url” parameter as the background of the button.
Example:
bt_Icon(el(BT123), 'Images/MD/Content/ic_add_white_18dp.png');
void bt_PleaseWait(object bt)
The function displays a “loading” state on the button – saves the original value and width of the button and displays the text “Please wait…”. The button is also disabled.
Example:
bt_PleaseWait(el(BT123));
void bt_PleaseWait2(object bt)
The function restores the button to its original state after loading is complete (counterpart of “bt_PleaseWait”).
Example:
bt_PleaseWait2(el(BT123));
void button_Disable(o)
The function disables the button specified by the “o” parameter in the edit form.
Example:
button_Disable(BT123);
void button_Enable(o)
The function enables the button specified by the “o” parameter in the edit form.
Example:
button_Enable(BT123);
void buttons_Disable()
The function disables all buttons in the edit form.
Example:
buttons_Disable();
void buttons_Enable()
The function enables all buttons in the edit form.
Example:
buttons_Enable();
void cb_Disable(object cb)
The function disables editing of the “ComboBox” control specified by the “cb” parameter. An alternative is the general function “control_Disable”.
Example:
cb_Disable(#ng_combobox#);
void cb_Enable(object cb)
The function enables editing of the “ComboBox” control specified by the “cb” parameter. An alternative is the general function “control_Enable”.
Example:
cb_Enable(#ng_combobox#);
void chb_Disable(object chb)
The function disables editing of the “CheckBox” control specified by the “chb” parameter. An alternative is the general function “control_Disable”.
Example:
chb_Disable(#ng_checkbox#);
void chb_Display(object chb, object o, bool reverse)
The function hides or shows the element specified by the “o” parameter depending on whether the checkbox defined by the “chb” parameter is checked. The optional “reverse” parameter (default “false”) inverts the behavior: when “true”, the element is hidden if the checkbox is checked. The function is mainly used in the “OnClick” event of a checkbox.
Example:
chb_Display(this, 'D1');
chb_Display(this, 'D1', true);
chb_Display(this, #ng_textbox#);
chb_Display(this, #ng_textbox#, true);
chb_Display(#ng_checkbox#, 'D1');
chb_Display(#ng_checkbox#, #ng_textbox#);
void chb_Enable(object chb)
The function enables editing of the “CheckBox” control specified by the “chb” parameter. An alternative is the general function “control_Enable”.
Example:
chb_Enable(#ng_checkbox#);
string Color2Hex(string value)
string Color2Hex(string value, string def)
The function formats the color specified by the “value” parameter into hexadecimal format “#rrggbb”. The function can process:
- Format “R,G,B” (e.g. “255,0,0” returns “#ff0000”)
- 6-character hex without # (e.g. “ff0000” returns “#ff0000”)
- 7-character hex with # (e.g. “#ff0000” returns “#ff0000”)
- Prefixes “B”, “I”, “BI”, “IB”, “N” are automatically removed before processing
- Conditional date-based color format: “color@date1@color1@date2@color2” – returns color based on the current date
If the value cannot be processed, it returns the “def” parameter, or “#ffffff” if “def” is not specified.
Example:
var s = Color2Hex('255,128,0'); // Returns “#ff8000”
var s = Color2Hex('B#336699'); // Returns “#336699” (prefix B removed)
var s = Color2Hex('invalid', '#000000'); // Returns “#000000”
bool confirm2(string value)
The function displays a native browser confirm dialog with the text specified by the “value” parameter. Before displaying, it removes HTML tags and replaces “ ” entities with a space. Resets the internal guard flags “_form_Update” and “_bt_Click”. Returns “true” if the user confirms, “false” if they decline.
Example:
if (!confirm2('Do you really want to delete this record?')) return false;
bool confirm3(string value)
The function displays a native browser confirm dialog with the text specified by the “value” parameter without any content modification. Resets the internal guard flags in the same way as “confirm2”. Returns “true” or “false”.
Example:
if (!confirm3('Really delete?')) return false;
void control_Disable(object o)
The function disables editing of the control defined by the “o” parameter. Internally recognizes the control type (TextBox, ComboBox, ForeignKey, CheckBox, etc.) and calls the corresponding type-specific function.
Example:
control_Disable(#ng_control#);
void control_Disable(object o, bool disableLink)
The function disables editing of the control defined by the “o” parameter. The optional “disableLink” parameter (true/false) determines whether the link to the selected record is to be deactivated for the “ForeignKey” control.
Example:
control_Disable(#ng_control#);
control_Disable(#ng_control#, false);
void control_Enable(object o)
The function enables editing of the control defined by the “o” parameter.
Example:
control_Enable(#ng_control#);
void control_Enable(object o, bool ignorereadonly)
The function enables editing of the control. If the “ngreadonly” attribute is set, the function respects it by default and does not enable the control. Setting “ignorereadonly=true” overrides this behavior and enables the control even if “ngreadonly” is set.
Example:
control_Enable(#ng_control#, true);
string control_GetValue(object o)
The function returns the value of the database control specified by the “o” parameter. Behavior by control type:
- “TextBox” with time – returns both date and time (format “dd.MM.yyyy HH:mm”)
- “MultiListBox” – returns selected values separated by a tab (\t); internally replaces the separator [*VS*]
- “Radio” – returns the value of the selected radio button
- “CheckBox” – returns the value of the “chv” attribute (value when checked) or “” when unchecked
- “RichTextBox” – returns the innerHTML of the body element in the iframe
- “ComboBox”/“ForeignKey”/“ListBox” – returns the value from INPUT or SELECT depending on the implementation
Example:
var s = control_GetValue(#ng_control#);
void control_ResizeTable(object o, int width)
The function sets the width of the table in which the control specified by the “o” parameter is displayed to the new width specified by the “width” parameter.
Example:
control_ResizeTable(#ng_control:Table#, 60);
void control_Save(object o)
The function stores the value of the database control in the database using ajax. “OnBeforeSave” and “OnAfterSave” events are not executed when saved.
Example:
control_Save(#ng_control#);
void control_Save(object o, string f, string errorMessage)
The function stores the value of the database control in the database using ajax. The “f” parameter is a callback called after the server response (returns “OK” or “ERROR”). The “errorMessage” parameter defines the text of the error message.
Example:
control_Save(#ng_control#, ajaxResponse, 'An error has occurred');
function ajaxResponse(status)
{
alert(status);
}
void control_SetDirection(object o, string direction)
The function sets the text direction (RTL/LTR) on a “TextBox”, “TextArea”, or “RichTextBox” control.
Example:
control_SetDirection(#ng_textbox#, 'rtl');
control_SetDirection(#ng_textbox#, 'ltr');
void control_SetValue(object o, var value [, var value2])
The function inserts the value defined by the “value” parameter into the database control specified by the “o” parameter. Details:
- “TextBox” with Date or DatePicker validation: “value” can be a string “dd.MM.yyyy HH:mm” or a Date object. The optional “value2” is the time “HH:mm” (only for TextBox with time).
- “CheckBox”: if “value” is a boolean, it directly sets the checked state. If it is a string, it is compared with the “chv” attribute.
- “ForeignKey”: sets the value and updates the visual display of the control.
- “DatePicker”: after setting, triggers onchange.
- “MultiListBox”: supports searching for values via the “value2” parameter (array of values).
Example:
control_SetValue(#ng_control#, 'Text');
control_SetValue(#ng_textbox#, 20);
control_SetValue(#ng_textbox#, '1.1.2000');
control_SetValue(#ng_textbox#, '1.1.2000', '12:34');
control_SetValue(#ng_textbox#, new Date());
control_SetValue(#ng_datepicker#, '1.1.2000');
control_SetValue(#ng_datepicker#, '1.1.2000 12:34');
control_SetValue(#ng_datepicker#, new Date());
control_SetValue(#ng_checkbox#, true);
control_SetValue(#ng_checkbox#, 'x');
control_SetValue(#ng_foreignkey#, 20);
void controls_Disable()
The function disables editing of all controls (except buttons) in the edit form.
Example:
controls_Disable();
void controls_Disable(bool disableLinks)
The function disables editing of all controls (except buttons) in the edit form. The optional “disableLinks” parameter (true/false) determines whether the link to the selected record is to be deactivated for “ForeignKey” controls.
Example:
controls_Disable();
controls_Disable(false);
void controls_Enable()
The function enables editing of all controls (except buttons) in the edit form.
Example:
controls_Enable();
void controls_Join(object[] array [, function onchange])
The function combines the controls defined by the “array” parameter into a group that displays only the controls with a filled value, plus one additional empty one. When a value changes, the group is automatically redrawn. The “onchange” parameter is an optional callback called on every change; “null” means group initialization (without callback).
Example:
controls_Join([#ng_control1#, #ng_control2#, #ng_control3#]);
controls_Join(new Array(#ng_control1#, #ng_control2#, #ng_control3#));
void controls_Save(object[] array)
The function stores the values of database controls in the database using ajax. “OnBeforeSave” and “OnAfterSave” events are not executed when saved.
Example:
controls_Save([#ng_control1#, #ng_control2#]);
controls_Save(new Array(#ng_control1#, #ng_control2#));
void controls_Save(object[] array, string f, string errorMessage)
The function stores the values of database controls in the database using ajax. The “f” parameter is a callback (returns “OK” or “ERROR”). The “errorMessage” parameter defines the text of the error message.
Example:
controls_Save([#ng_control1#, #ng_control2#], ajaxResponse, 'An error has occurred');
function ajaxResponse(status)
{
alert(status);
}
string cookie_Get(string name)
The function returns the content of the cookie specified by the “name” parameter from the page. Reads from document.cookie.
Example:
var s = cookie_Get('loginname');
void cookie_Set(string name, string value)
The function saves a cookie to the server using an AJAX call to the “SaveCookie.aspx” page. This is not a standard client-side cookie – the value is stored on the server and persists across sessions. The function accepts optional parameters “f” (callback), “id” and “errorMessage”.
Note: This function does not set document.cookie directly. It is a server-side operation.
Example:
cookie_Set('TestCookie', 'Test cookie');
bool copyToClipboard(string value, string info)
The function copies the value specified by the “value” parameter to the clipboard. The “info” parameter defines the text of the informational message displayed after a successful copy. If the insert is not successful, the function returns “false”.
Example:
copyToClipboard('Value to be pasted into clipboard', 'Value successfully pasted into clipboard.');
object[] createDictionary(array value)
The function creates an associative array (dictionary) from a flat array in the format [key1, value1, key2, value2, …]. Even indices are keys, odd indices are values.
Example:
var dict = createDictionary(['cs', 'Czech', 'en', 'English', 'de', 'German']);
alert(dict['cs']); // Returns “Czech”
alert(dict['en']); // Returns “English”
object Date (prototype extension)
The Date type is extended with the following methods:
- “.addDays(n)” – adds n days, returns a new Date object
- “.addWorkDays(n)” – adds n working days (skips weekends and holidays), returns a new Date
- “.addMonths(n)” – adds n months, returns a new Date
- “.addYears(n)” – adds n years, returns a new Date
- “.addHours(n)” – adds n hours, returns a new Date
- “.addMinutes(n)” – adds n minutes, returns a new Date
- “.monday()” – returns the Monday of the current week
- “.isWeekend()” – returns true if the date is a Saturday or Sunday
- “.isLeapYear()” – returns true if it is a leap year
- “.getDaysInMonth()” – returns the number of days in the month
- “.clone()” – returns a copy of the Date object (preserves date and time)
- “.clone2()” – returns a copy of Date with zero time (00:00:00)
Example:
var d = new Date();
var tomorrow = d.addDays(1);
var nextMonth = d.addMonths(1);
var monday = d.monday();
var isWeekend = d.isWeekend();
var daysInMonth = d.getDaysInMonth();
object Date.addWorkDays(int n)
Adds “n” working days to the date, skipping weekends and holidays stored in “holidays1Cache_Array” and “holidays2Cache_Array”. A negative value of “n” subtracts working days.
Example:
var d = new Date(2024, 0, 1); // January 1 (Monday)
var nextWorkDay = d.addWorkDays(1); // January 2 (Tuesday, if not a holiday)
string Date2Str(object date)
The function returns a text string from the date specified by the “date” parameter. If the time is 00:00, it returns only “dd.MM.yyyy”; otherwise “dd.MM.yyyy HH:mm”.
Example:
var s = Date2Str(new Date());
var s = Date2Str(new Date(2000, 0, 1)); // Returns “1.1.2000”
void ddl_ReplaceItems(object ddl, object array [, bool options])
The function replaces the items of the drop-down list “ddl” with values from the “array” field. Each array element is [value, text]. Preserves the current selection. If the third parameter is “true”, the array elements are treated as DOM option objects and inserted directly.
Example:
var array = [];
array.push(['1', 'First item']);
array.push(['2', 'Second item']);
array.push(['3', 'Third item']);
ddl_ReplaceItems(#ng_combobox#, array);
void ddl_ReplaceTexts(object ddl, object array, string separator)
The function replaces the texts of items in the drop-down list “ddl” with values from the “array” field. Each array element is [value, newText]. With the “separator” parameter: the new text will be “value + separator + newText”. Without separator: the new text will be only “newText”. Does not affect the stored value.
Example:
var array = [];
array.push(['1', 'First item']);
array.push(['2', 'Second item']);
array.push(['3', 'Third item']);
ddl_ReplaceTexts(#ng_combobox#, array);
// ddl_ReplaceTexts(#ng_combobox#, array, ' – ');
string ddl_SelectedItem_Text(object ddl)
The function returns the text of the selected item in the drop-down list specified by the “ddl” parameter.
Example:
var s = ddl_SelectedItem_Text(#ng_combobox#);
string ddl_SelectedItem_Value(object ddl)
The function returns the value of the selected item in the drop-down list specified by the “ddl” parameter.
Example:
var s = ddl_SelectedItem_Value(#ng_combobox#);
bool ddl_SelectText(object ddl, string text)
The function searches for an item in the drop-down list “ddl” by its text and selects it. Calls the “onchange” event. If the item is not found, returns “false”.
Example:
var ok = ddl_SelectText(#ng_combobox#, 'Prague');
bool ddl_SelectText_NoChange(object ddl, string text)
Same as “ddl_SelectText”, but the “onchange” event is not called.
Example:
var ok = ddl_SelectText_NoChange(#ng_combobox#, 'Prague');
bool ddl_SelectValue(object ddl, string value)
The function searches for an item in the drop-down list “ddl” by its value and selects it. Calls the “onchange” event. If the item is not found, returns “false”.
Example:
var ok = ddl_SelectValue(#ng_combobox#, '1');
bool ddl_SelectValue_NoChange(object ddl, string value)
Same as “ddl_SelectValue”, but the “onchange” event is not called.
Example:
var ok = ddl_SelectValue_NoChange(#ng_combobox#, '1');
void ddl_SortByText(object ddl)
The function sorts the items in the “ddl” drop-down list alphabetically according to the texts of the individual items.
Example:
ddl_SortByText(#ng_combobox#);
void ddl_SortByText2(object ddl)
The function numerically sorts the items in the “ddl” drop-down list according to the texts of the individual items.
Example:
ddl_SortByText2(#ng_combobox#);
void ddl_SortByValue(object ddl)
The function sorts the items in the “ddl” drop-down list alphabetically according to the values of the individual items.
Example:
ddl_SortByValue(#ng_combobox#);
void ddl_SortByValue2(object ddl)
The function numerically sorts the items in the “ddl” drop-down list according to the values of the individual items.
Example:
ddl_SortByValue2(#ng_combobox#);
void detachEvent2(object o, string type, function listener)
The function disconnects the “listener” function from the “o” object event.
Example:
attachEvent2(window, 'load', test);
detachEvent2(window, 'load', test);
function test()
{
alert('onload');
}
void dg_ColumnWidth(object dg, int cid, int width)
The function sets the width of column “cid” in the datagrid “dg” to the value “width” (in pixels).
Example:
dg_ColumnWidth(DG123, 456, 200);
object[] dg_Controls(object dg)
The function returns an array of all editable controls within the datagrid “dg”.
Example:
var array = dg_Controls(DG123);
void dg_DenyOpen(object dg)
The function disables opening records from the datagrid by clicking.
Example:
dg_DenyOpen(DG123);
void dg_Disable()
The function disables editing of all controls intended for mass editing in all datagrids.
Example:
dg_Disable();
void dg_Disable(object dg)
The function disables editing of all controls intended for mass editing in a specific datagrid.
Example:
dg_Disable(DG123);
void dg_Enable()
The function enables editing of all controls intended for mass editing in all datagrids.
Example:
dg_Enable();
void dg_Enable(object dg)
The function enables editing of all controls intended for mass editing in a specific datagrid.
Example:
dg_Enable(DG123);
bool dg_HideColumn(object dg, int cid)
The function hides the column specified by the “cid” parameter in the datagrid “dg”. The column ID corresponds to the control ID.
Example:
dg_HideColumn(DG123, 123);
void dg_HideHeader(object dg)
The function hides the title of the datagrid. The parameter can be a datagrid object or a string with the title.
Example:
dg_HideHeader(DG123);
dg_HideHeader('Table title');
void dg_SearchColumns(object dg, array cids)
The function checks the search for columns defined by the “cids” array in the datagrid “dg”.
Example:
dg_SearchColumns(DG123, [1, 2, 3]);
bool dg_ShowColumn(object dg, int cid)
The function displays the hidden column “cid” in the datagrid “dg”.
Example:
dg_ShowColumn(DG123, 123);
void dg_Update(object dg [, function f])
The function reloads the datagrid “dg” using AJAX. The optional “f” parameter is a callback called after loading is complete.
Example:
dg_Update(DG123);
dg_Update(DG123, function() { alert('Datagrid has been refreshed.'); });
void dg_VisibleColumns(object dg, array cids)
The function sets the visible columns in the datagrid “dg”. Hides all columns not in the “cids” array.
Example:
dg_VisibleColumns(DG123, [1, 2, 3]);
void dp_Disable(object dp)
The function disables editing of the “DatePicker” control specified by the “dp” parameter.
Example:
dp_Disable(#ng_datepicker#);
void dp_Enable(object dp)
The function enables editing of the “DatePicker” control specified by the “dp” parameter.
Example:
dp_Enable(#ng_datepicker#);
object el(string id)
The function returns a DOM object on the web page according to its ID. A wrapper for document.getElementById.
Example:
var bt = el(BT1665);
// Returns a button object with database ID 1665
void evalGoogleCaptcha()
The function triggers Google reCAPTCHA validation.
Example:
evalGoogleCaptcha();
void file_Disable(object file)
The function disables editing of the “File” control.
Example:
file_Disable(#ng_file#);
void file_Enable(object file)
The function enables editing of the “File” control.
Example:
file_Enable(#ng_file#);
void fireEvent2(object o, string type)
The function raises an event on the “o” object. The “type” parameter is the type of event. Supported types: blur, click, dblclick, change, keyup, mousedown, mouseout, mouseover. Other types are processed via an eval fallback.
Example:
fireEvent2(#ng_control#, 'change');
void fk_Disable(object fk, bool disableLink)
The function disables editing of the “ForeignKey” control. The “disableLink” parameter determines whether to deactivate the link to the selected record.
Example:
fk_Disable(#ng_foreignkey#);
fk_Disable(#ng_foreignkey#, false);
void fk_Enable(object fk)
The function enables editing of the “ForeignKey” control.
Example:
fk_Enable(#ng_foreignkey#);
void fk_Update(object fk)
The function updates the display of the “ForeignKey” control using AJAX. This is relevant when the control width is set to zero after using “control_SetValue”.
Example:
fk_Update(#ng_foreignkey#);
void form_Change()
The function is called whenever the value of a control in the edit form changes. It sets the flag “_form_Change=true” and ensures that a warning is displayed when leaving the form without saving. If AutoSave is enabled, it starts a 5-second timer for automatic saving.
Example:
form_Change();
void form_DisableUpdate()
The function prevents the automatic update of the edit form after copying file attachments or images using a picker, or after copying values into drop-down lists or radio buttons.
Example:
form_DisableUpdate();
bool form_Picker()
The function returns the boolean value “true” if the form is in the state of calling JavaScript “onchange” events of controls whose values have just been taken over by the picker. Internally tests the presence and state of the hidden field “ng-picker”.
Example:
var ok = form_Picker();
void form_Save([function f])
The function saves all control values of the form to the database using AJAX to the “Save.aspx” page. The optional “f” parameter is a callback called after successful saving. After saving, it calls “form_Saved()” to reset the change flag.
Example:
form_Save();
form_Save(function() { alert('Saved.'); });
void form_SetMargins(int top, int right, int bottom, int left)
The function sets the page margins (in pixels). Used for printing or layout adjustments.
Example:
form_SetMargins(10, 20, 10, 20);
void form_Update()
The function updates the currently open edit form – primarily to refresh data in datagrids or data sources of individual controls. Internally triggers “bt_Click()” (postback). If the form is currently in a picker state (“form_Picker()” returns “true”), the update is deferred by 500 ms. The function respects the guard flag “_form_Update” – if it was set to “false”, calling it has no effect.
Example:
form_Update();
string Hex(int n)
The function converts the decimal number specified by the “n” parameter to a two-character hexadecimal string (lowercase letters). If the result is single-character, it is padded with a leading zero.
Example:
var s = Hex(123); // Returns “7b”
var s = Hex(15); // Returns “0f”
var s = Hex(255); // Returns “ff”
string html_showWindow(string html, string bt1title, string/function bt1f, string bt2title, string/function bt2f)
The function displays a modal dialog with custom HTML content. Optional parameters define 1 or 2 buttons. The “bt*f” parameter can be a string (onclick code) or a direct function reference. Returns the dialog ID.
Example:
html_showWindow('<p>Do you really want to delete this record?</p>', 'Yes', 'bt_Click(BT123)', 'No', null);
string htmlEncode(string value)
The function encodes special HTML characters in the string. Encodes: & returns &, < returns <, > returns >, "" returns ", ' returns '.
Example:
var s = htmlEncode('<script>alert(“xss”)</script>');
// Returns “<script>alert("xss")</script>”
void image_Disable(object image)
The function disables editing of the “Image” control specified by the “image” parameter. An alternative is the general function “control_Disable”.
Example:
image_Disable(#ng_image#);
void image_Enable(object image)
The function enables editing of the “Image” control specified by the “image” parameter. An alternative is the general function “control_Enable”.
Example:
image_Enable(#ng_image#);
int innerHeight2([object o])
The function returns the inner height of the window specified by the “o” parameter in pixels. If the “o” parameter is not specified, the “window” object is used. Works correctly across different browsers (IE/Edge, Firefox, Safari, Chrome).
Example:
var n = innerHeight2();
int innerWidth2([object o])
The function returns the inner width of the window specified by the “o” parameter in pixels. If the “o” parameter is not specified, the “window” object is used. Works correctly across different browsers (IE/Edge, Firefox, Safari, Chrome).
Example:
var n = innerWidth2();
void InsertTime(object tb)
The function inserts the current time in the format “HH:mm” into the text field defined by the “tb” parameter.
Example:
InsertTime(#ng_textbox#);
string Int2Roman(int n)
The function converts an integer to Roman numerals. Supports values 1–3999. Returns an empty string for values outside this range.
Example:
var s = Int2Roman(14); // Returns “XIV”
var s = Int2Roman(2024); // Returns “MMXXIV”
var s = Int2Roman(0); // Returns “”
string Int2Time(int n)
The function converts a total number of minutes to time in the format “HH:MM”. Correctly handles negative values.
Example:
var s = Int2Time(90); // Returns “1:30”
var s = Int2Time(-15); // Returns “-0:15”
var s = Int2Time(0); // Returns “0:00”
bool isImage(string filename)
The function returns “true” if the filename has an image extension (jpg, jpeg, gif, png, bmp, svg, webp, tif, tiff).
Example:
var b = isImage('photo.jpg'); // Returns true
var b = isImage('document.pdf'); // Returns false
void jsClose([string message])
The function closes the current iframe dialog or window. The optional “message” parameter is passed as a return value to the parent window.
Example:
jsClose();
jsClose('OK');
void jsClose2(string id)
The function closes a specific iframe dialog identified by the “id” parameter. Removes the dialog from the “doc.htmlDialogs” array and from the DOM. If it was the last open dialog, restores the page scroll to the original position.
Example:
var id = html_showWindow('<p>Dialog content</p>', 'Close', null, null, null);
jsClose2(id);
string jsCompanyWithoutSro(string value)
The function removes Czech/Slovak legal suffixes (s.r.o., a.s., spol. s r.o., v.o.s., k.s., o.p.s., z.ú., s.e., SE, etc.) from the beginning and end of the company name string.
Example:
var s = jsCompanyWithoutSro('ABC s.r.o.'); // Returns “ABC”
var s = jsCompanyWithoutSro('a.s. XYZ'); // Returns “XYZ”
string jsConfirm(string html, object[] buttons)
The function displays a modal confirmation dialog (not a native browser confirm). The “html” parameter is the dialog content. The “buttons” parameter is an array of objects with “title” and “f” properties. Returns the dialog ID.
Example:
jsConfirm('Really delete?', [
{ title: 'Yes', f: function() { bt_Click(BT123); } },
{ title: 'No', f: null }
]);
void jsDisplay(bool value)
The function returns the string “” (visible) if “value” is true, or “'none'” (hidden) if it is false. Suitable for setting style.display.
Example:
#ng_:Table#.style.display = jsDisplay(condition);
string jsFN(double n)
string jsFormatNumber(double n)
The function formats the number specified by the “n” parameter into the text form required for the correct storage of a numeric value in the database – it ensures the use of the correct decimal separator based on the “numberSeparator” variable. The “jsFormatNumber” function is an alias for “jsFN”.
Example:
control_SetValue(#ng_textbox#, jsFN(1.23));
#ng_textbox#.value = jsFN(1.23);
string jsFormatCurrency(number n, string symbol)
The function formats a number as an amount with spaces as thousands separators, a comma as the decimal separator, and 2 decimal places. The optional “symbol” parameter is appended after the number.
Example:
var s = jsFormatCurrency(1234567.89, 'CZK'); // Returns “1 234 567,89 CZK”
string jsFormatDate(object date)
The function formats the date specified by the “date” parameter into text based on the date format from the NET Genium settings (“dd.MM.yyyy” or “MM/dd/yyyy”) and the language settings of the currently logged in user (slash as separator for English, otherwise period).
Example:
var s = jsFormatDate(new Date());
// Returns the current date, e.g. “20.04.2026” (language other than English)
var s = jsFormatDate(Str2Date('01.01.2016 13:00'));
// Returns “01.01.2016”
string jsFormatDouble(number n [, string symbol])
The function formats a number with spaces as thousands separators and a comma as the decimal separator. The number of decimal places corresponds to the input number (variable). The optional “symbol” parameter is appended after the number.
Example:
var s = jsFormatDouble(1234.5); // Returns “1 234,5”
var s = jsFormatDouble(1234.56, 'kg'); // Returns “1 234,56 kg”
string jsFormatSize(number n)
The function formats a file size in bytes into a readable format (b / kB / MB).
Example:
var s = jsFormatSize(1024); // Returns “1 kB”
var s = jsFormatSize(1048576); // Returns “1 MB”
var s = jsFormatSize(512); // Returns “512 b”
string jsFormatTable(string value, string title, int width, bool showGrid, string noEntries, int pageSize, int tb_pageIndex)
The function renders a complete datagrid HTML from tabular data. The “value” parameter is CSV-like data (rows separated by \n, columns by \t). The first row of data is the header. A cell with value “null” causes a colspan of the adjacent column. Column alignment: prefix | = left, suffix | = right, both prefix and suffix | = center. Column width: suffix ! = width in pixels. Supports pagination via “pageSize” and “tb_pageIndex”.
Example:
var data = 'Name\tAge\nJohn\t30\nPetra\t25';
var html = jsFormatTable(data, 'Overview', 500, true, 'No records', 10, 0);
el('ng-output').innerHTML = html;
string jsFormatTable2(string value, int width, string noEntries)
A simplified version of “jsFormatTable” without a grid and with minimal formatting.
Example:
var html = jsFormatTable2(data, 400, 'No records');
string jsFormatTime(object date)
The function formats the time specified by the “date” parameter into text in the format “HH:mm”.
Example:
var s = jsFormatTime(new Date());
// Returns the current time, e.g. “14:35”
var s = jsFormatTime(Str2Date('1.1.2016 13:00'));
// Returns “13:00”
string jsFormatTime2(object date)
The function formats the time specified by the “date” parameter into text in the format “HH:mm:ss”.
Example:
var s = jsFormatTime2(new Date());
// Returns the current time, e.g. “14:35:22”
var s = jsFormatTime2(Str2Date('1.1.2016 13:00'));
// Returns “13:00:00”
string jsFormatTime3(object date)
The function formats the time specified by the “date” parameter into text in the format “HH:mm:ss.SSS” (including milliseconds).
Example:
var s = jsFormatTime3(new Date());
// Returns the current time, e.g. “14:35:22.456”
var s = jsFormatTime3(Str2Date('1.1.2016 13:00'));
// Returns “13:00:00.0”
bool jsIsNumber(object o)
The function returns the boolean value “true” if the value specified by the “o” parameter is a number (after optionally replacing a comma with a period), or “false” otherwise. Tests whether the value is within the range of -1,000,000,000,000 to 1,000,000,000,000.
Example:
var ok = jsIsNumber(#ng_textbox#.value);
var ok = jsIsNumber('1 234,56'); // Returns false (space not allowed)
var ok = jsIsNumber('1234,56'); // Returns true
double jsMeasureHours(Date startDate, Date endDate)
The function returns the number of hours between two dates. If the time of the end date is 00:00, it is treated as end of day (midnight), not the beginning of the day.
Example:
var h = jsMeasureHours(new Date(2024, 0, 1, 8, 0), new Date(2024, 0, 1, 16, 0)); // Returns 8
double jsMeasureMinutes(Date startDate, Date endDate)
The function returns the unrounded number of minutes from the time period specified by the “startDate” and “endDate” parameters. Both parameters must be JavaScript objects of type “Date”. Internally calls “jsMeasureHours” and multiplies the result by 60.
Example:
var n = jsMeasureMinutes(Str2Date('1.1.2000'), Str2Date('1.2.2000'));
var n = jsMeasureMinutes(new Date(2024, 0, 1, 8, 0), new Date(2024, 0, 1, 8, 30)); // Returns 30
double jsMeasureWorkDays(Date startDate, Date endDate [, int workingHours])
The function returns the number of working days between two dates. Excludes weekends, public holidays from “holidays1Cache_Array” (full day) and holidays from “holidays2Cache_Array” (half day). The “workingHours” parameter allows calculation in fractions of a day (e.g. 8 hours = 1 working day).
Example:
var d = jsMeasureWorkDays(new Date(2024, 0, 1), new Date(2024, 0, 31));
var d = jsMeasureWorkDays(new Date(2024, 0, 1), new Date(2024, 0, 31), 8);
number jsN(var o [, var o2])
The function safely converts a value to a number. Handles comma as a decimal separator. Returns 0 for null, empty string, or values out of range. The optional “o2” parameter is added as the decimal part.
Example:
var n = jsN('1 234,56'); // Returns 1234.56
var n = jsN(null); // Returns 0
var n = jsN('3', '14'); // Returns 3.14
string jsNetGeniumStart(string date)
The function returns the time of the first start of NET Genium by the currently logged in user on the day specified by the text parameter “date” in the format “dd.MM.yyyy”. Reads the start time information from cookies (key “NG” + date without separators).
Example:
var s = jsNetGeniumStart('#today#');
string jsngdph()
The function returns the current VAT rates for the Czech Republic separated by a semicolon (e.g. “21;15;12;0”).
Example:
var s = jsngdph();
// Returns the current VAT rates for the Czech Republic, e.g. “21;15;12;0”
double jsngdph(int rate)
The function returns the current VAT rate for the Czech Republic according to the index specified by the “rate” parameter: 1 = reduced rate, 2 = increased rate, 3 = second reduced rate, 0 = zero rate.
Example:
var n = jsngdph(2);
// Returns the increased VAT rate, e.g. 21
var n = jsngdph(1);
// Returns the reduced VAT rate, e.g. 15
string jsngdph(object date)
The function returns the VAT rates for the Czech Republic valid on the date specified by the “date” parameter (JavaScript Date object), separated by a semicolon.
Example:
var s = jsngdph(Str2Date('1.1.2013'));
// Returns VAT rates valid on 1.1.2013, e.g. “21;15;0”
double jsngdph(int rate, object date)
The function returns the VAT rate for the Czech Republic defined by the “rate” parameter valid on the date specified by the “date” parameter.
Example:
var n = jsngdph(2, Str2Date('1.1.2000'));
// Returns the increased VAT rate valid on 1.1.2000, e.g. 22
string jsngdph(double base, string type1, double rate, string type2 [, bool vyuctovanidph])
A function for VAT calculations. The “base” parameter is the input amount, “type1” specifies its type (“bezdph” or “sdph”), “rate” is the VAT rate in percent (or a ComboBox object with VAT rates), “type2” determines the output. The optional “vyuctovanidph” parameter (“true”) changes the calculation method for billing.
Possible values for the “type2” parameter:
- “bezdph” – calculates the tax base
- “dph” – calculates the VAT value
- “zdph” – VAT rounded up to a whole number
- “dph1” – VAT of the reduced rate
- “zdph1” – VAT of the reduced rate rounded up
- “dph2” – VAT of the increased rate
- “zdph2” – VAT of the increased rate rounded up to an integer
- “sdph” – amount with VAT
- “zsdph” – amount with VAT rounded up to a whole number
- “zsdph-1” – amount with VAT rounded mathematically to an integer
- “zsdph-2” – amount with VAT rounded to 50 pennies
Example:
// Price without VAT › price with VAT (rate 21%)
var s = jsngdph(1000, 'bezdph', 21, 'sdph'); // Returns “1210”
// Price with VAT › tax base
var s = jsngdph(1210, 'sdph', 21, 'bezdph'); // Returns “1000”
// Calculation of the VAT value
var s = jsngdph(1000, 'bezdph', 21, 'dph'); // Returns “210”
int jsngvatindex(double rate [, object dph])
The function returns the index of the VAT rate specified by the “rate” parameter. Returns “0” for the zero rate, “1” for the reduced rate, “2” for the increased rate, “3” for the second reduced rate. The optional “dph” parameter is a ComboBox object with VAT rates – if specified, the index is derived from the values in the ComboBox.
Example:
var n = jsngvatindex(0); // Returns 0
var n = jsngvatindex(15); // Returns 1
var n = jsngvatindex(21); // Returns 2
var n = jsngvatindex(10); // Returns 3
string jsngvatrates(string country, object date)
The function returns an array of VAT rates for the given country (ISO code, e.g. “CZ”, “DE”, “SK”, “HU”, …) valid on the date specified by the “date” parameter. Values are sorted from the highest to the lowest rate.
Example:
var rates = jsngvatrates('CZ', new Date()); // Returns e.g. [21, 15, 12]
var rates = jsngvatrates('DE', Str2Date('1.1.2013')); // Returns [19, 7]
number jsNumber(var o [, var o2])
An alias for the “jsN” function. Safely converts a value to a number. Handles comma as a decimal separator.
Example:
var n = jsNumber('1 234,56'); // Returns 1234.56
var n = jsNumber(null); // Returns 0
string jsNumberInWords(number n, string language)
The function converts a number to its text representation in words. Supported languages: “cz”/“cs” (Czech), “sk” (Slovak), “de” (German), “en” (English), “fr” (French). Supports values up to billions.
Example:
var s = jsNumberInWords(1234, 'cz'); // Returns “tisíc dvěstě třicet čtyři”
var s = jsNumberInWords(42, 'en'); // Returns “forty-two”
object jsO(object o)
The function converts the “o” object to a safe object – if “o” is null or a number (meaning the value of a control the user does not have access to), it returns “null”; otherwise it returns the original object. The function is used to test the user's rights to a control.
Example:
var o = jsO(#ng_tb#);
// If the user does not have rights to the '#ng_tb#' control,
// '#ng_tb#' is replaced by the value from the database – jsO() then returns null
if (o != null)
{
// control is accessible
}
void jsOpen(string url)
The function opens a URL in an iframe dialog (overlay) within the current page. Exception: the DownloadFile.aspx page is opened as a real browser popup window. On mobile devices, a popup is always opened.
Example:
jsOpen('ViewPage.aspx?appgroup=1&app=2&viewpage=3&id=100');
void jsPost([string action, function f, bool loader])
The function submits all form values using the POST method to the current URL (or to “action”). The optional “f” parameter is a callback after the response. The “loader” parameter displays a loading indicator. Handles navigation response headers for redirects.
Example:
jsPost();
jsPost('Save.aspx', function(html) { alert(html); });
string jsProgressBar(int width, int done, string color)
The function returns an HTML string for a visual progress bar. The “width” parameter is the total width (px), “done” is the percentage (0–100), “color” is the fill color.
Example:
var html = jsProgressBar(200, 75, '#4caf50');
el('ng-progress').innerHTML = html;
double jsR(number n [, int decimals])
double jsRound(number n [, int decimals])
The function rounds a number to the specified number of decimal places. Correctly handles negative numbers (unlike Math.round). The “decimals” parameter is optional with a default value of 0. The “jsRound” function is an alias for “jsR”.
Example:
var n = jsR(2.567, 2); // Returns 2.57
var n = jsR(-2.5); // Returns -3 (correct mathematical rounding)
var n = jsR(2.5); // Returns 3
var n = jsRound(21.232); // Returns 21
double jsR_50(number n)
double jsRound_50(number n)
The function rounds the number specified by the “n” parameter to fifty pennies (i.e. to multiples of 0.5). The “jsRound_50” function is an alias for “jsR_50”.
Example:
var n = jsR_50(123.456); // Returns 123.5
var n = jsR_50(123.749); // Returns 123.5
var n = jsR_50(123.750); // Returns 124
var n = jsR_50(123.249); // Returns 123
void jsRefresh([object o, bool refresh, string id, string cmd])
The function refreshes the page while preserving the scroll position and tab state. Optional parameters allow specifying a control, refresh type, and command.
Example:
jsRefresh();
void jsResizeIframe(string id)
The function automatically sets the height of the iframe element with the given “id” to the height of its content.
Example:
jsResizeIframe('ng-iframe-123');
bool jsUserInGroup(string name)
The function checks whether the currently logged in user is a member of the user group specified by the “name” parameter. Uses the global “usergroups” array.
Example:
if (jsUserInGroup('Administrators')) {
// ...
}
bool jsValidateEmail(string value)
The function verifies whether the specified string is a valid e-mail address using a regular expression.
Example:
var ok = jsValidateEmail('user@example.com'); // Returns true
var ok = jsValidateEmail('invalid-email'); // Returns false
bool jsValidateEmails(string value)
The function verifies whether all e-mail addresses in the string are valid. Addresses are separated by a semicolon or comma.
Example:
var ok = jsValidateEmails('a@b.com; c@d.com'); // Returns true
string jsVisibility(bool value)
The function returns the string “'visible'” if “value” is true, or “'hidden'” if it is false. Suitable for setting style.visibility (the element remains in the layout but is not visible).
Example:
el('ng-element').style.visibility = jsVisibility(condition);
void jsWait(string url [, bool _pleaseWait, object _window, string errorMessage])
The function displays a loading indicator and navigates to the specified URL. The “_pleaseWait” parameter displays the text “Please wait…”. The “_window” parameter specifies the target window. The “errorMessage” parameter is displayed on error.
Example:
jsWait('ViewPage.aspx?appgroup=1&app=2');
void lb_Disable(object lb)
The function disables editing of the “ListBox” control specified by the “lb” parameter. An alternative is the general function “control_Disable”.
Example:
lb_Disable(#ng_listbox#);
void lb_Enable(object lb)
The function enables editing of the “ListBox” control specified by the “lb” parameter. An alternative is the general function “control_Enable”.
Example:
lb_Enable(#ng_listbox#);
bool letterOrDigit(string value)
The function returns “true” if the text specified by the “value” parameter begins with a letter (a–z, A–Z) or digit (0–9). Returns “false” if the text begins with a different character.
Example:
letterOrDigit('NET Genium'); // Returns true
letterOrDigit('-a**'); // Returns false
void loadUrl(string url)
The function loads the page defined by the “url” parameter using an asynchronous ajax call. The function does not wait for a response from the server. Only one call can be active at a time using “loadUrl” – if a previous call has not yet completed, a new call is skipped. For parallel calls, use “_loadUrl”.
Example:
var p0 = 'ěščřžýáíé', p1 = 'ĚŠČŘŽÝÁÍÉ';
loadUrl('ngef.aspx?MyFirstFunction,' + urlEncode(p0) + ',' + urlEncode(p1));
void loadUrl(string url, string/function f)
Same as the previous variant, but after receiving the response it calls the callback “f”. The HTML code of the page is passed to the “f” function as the first parameter.
Example:
var p0 = 'ěščřžýáíé', p1 = 'ĚŠČŘŽÝÁÍÉ';
loadUrl('ngef.aspx?MyFirstFunction,' + urlEncode(p0) + ',' + urlEncode(p1), ajaxResponse);
function ajaxResponse(html)
{
alert(html);
}
void loadUrl(string url, string/function f, string id)
Same as the previous variant. The optional “id” parameter is passed to the “f” function as the second parameter.
Example:
loadUrl('ngef.aspx?MyFirstFunction,' + urlEncode(p0), ajaxResponse, 'test');
function ajaxResponse(html, id)
{
alert(id + ': ' + html);
}
void loadUrl(string url, string/function f, string id, string params)
Same as the previous variant. The “params” parameter is sent using the POST method (format: key=value&key2=value2). If “params” is non-empty, POST is used; otherwise GET.
Example:
loadUrl('ngef.aspx?MyFirstFunction', ajaxResponse, 'test', 'p0=' + urlEncode(p0) + '&p1=' + urlEncode(p1));
function ajaxResponse(html, id)
{
alert(id + ': ' + html);
}
bool loginByFacebook()
The function triggers a login to a Facebook account in a new browser window. Successful login sets the value of the variable “#facebook_access_token#”. The function returns “false” if the user is already logged into Facebook (a valid token expiration exists).
Example:
var ok = loginByFacebook();
bool loginByGoogle(string scope, bool offline)
The function triggers a login to a Google account in a new browser window and passes the “scope” parameter defining the scope of access rights. Successful login sets the variable “#google_access_token#”. The “offline=true” parameter also sets “#google_refresh_token#”. Returns “false” if the user is already logged in.
Example:
var ok = loginByGoogle('https://www.googleapis.com/auth/youtube', false);
bool loginByMicrosoft(string scope, bool offline)
The function triggers a login to a Microsoft account in a new browser window and passes the “scope” parameter defining the scope of access rights. Successful login sets the variable “#microsoft_access_token#”. The “offline=true” parameter also sets “#microsoft_refresh_token#”. Returns “false” if the user is already logged in.
Example:
var ok = loginByMicrosoft('openid email', false);
class Mailbox
A class for parsing an e-mail address in the format “First Last email@domain.com” or '“Name” <email@domain.com>'. Properties:
- “.email()” – getter/setter for the e-mail address
- “.name()” – getter/setter for the name
Example:
var mb = new Mailbox('“John Smith” <john.smith@example.com>');
alert(mb.name()); // Returns “John Smith”
alert(mb.email()); // Returns “john.smith@example.com”
mb.email('new@email.com');
void mlb_Disable(object mlb)
The function disables editing of the “MultiListBox” control specified by the “mlb” parameter. An alternative is the general function “control_Disable”.
Example:
mlb_Disable(#ng_multilistbox#);
void mlb_Enable(object mlb)
The function enables editing of the “MultiListBox” control specified by the “mlb” parameter. An alternative is the general function “control_Enable”.
Example:
mlb_Enable(#ng_multilistbox#);
void mlb_Items_Delete(object lb)
The function removes the selected items from the “MultiListBox” control (internal select element “lb”). After removal, it selects the nearest remaining item.
Example:
mlb_Items_Delete(#ng_multilistbox#);
string mlb_Items_JoinTexts(object lb)
The function returns the texts of all items in the “MultiListBox” control joined by the separator “[*VS*]”.
Example:
var s = mlb_Items_JoinTexts(#ng_multilistbox#);
string mlb_Items_JoinValues(object lb)
The function returns the values of all items in the “MultiListBox” control joined by the separator “[*VS*]”.
Example:
var s = mlb_Items_JoinValues(#ng_multilistbox#);
bool mlb_Items_Move(object lb1, object lb2, bool column2, bool back, object lb)
The function moves the selected items from list “lb1” to list “lb2”. The “column2” parameter specifies special behavior for system column 2. The “back” parameter marks a reverse move. The optional “lb” parameter is the source list for preserving order. Returns “true” if the move was successful.
Example:
mlb_Items_Move(lb1, lb2, false, false, null);
void mlb_Items_MoveDown(object lb)
The function moves the selected item in the “MultiListBox” control one position down.
Example:
mlb_Items_MoveDown(#ng_multilistbox#);
void mlb_Items_MoveUp(object lb)
The function moves the selected item in the “MultiListBox” control one position up.
Example:
mlb_Items_MoveUp(#ng_multilistbox#);
string Now()
The function returns the current date and time in the format “dd.MM.yyyy HH:mm”.
Example:
var s = Now(); // Returns e.g. “20.4.2026 14:35”
string Now2()
The function returns the current date and time in the format “dd.MM.yyyy HH:mm:ss” (including seconds).
Example:
var s = Now2(); // Returns e.g. “20.4.2026 14:35:22”
int offsetLeft2(object o)
The function returns the x-coordinate of the element “o” from the top-left (or top-right in RTL mode) corner of the web page. Traverses the entire parent tree (“offsetParent”) and sums the offsets.
Example:
var n = offsetLeft2(#ng_textbox#);
int offsetTop2(object o)
The function returns the y-coordinate of the element “o” from the top edge of the web page. Traverses the entire parent tree (“offsetParent”) and sums the offsets.
Example:
var n = offsetTop2(#ng_textbox#);
void picker_Open(object o)
The function programmatically opens the picker of the control specified by the “o” parameter. Internally finds the picker button (element with “_p” suffix) and triggers its click.
Example:
picker_Open(#ng_textbox#);
string queryString(string name [, string url])
The function extracts the value of the “name” parameter from the URL query string. If the “url” parameter is not specified, “location.toString()” is used.
Example:
var id = queryString('id'); // from the current URL
var id = queryString('id', 'ViewPage.aspx?id=42'); // Returns “42”
int rbl_Count(object rbl)
The function returns the number of options in the radio button group “rbl”.
Example:
var n = rbl_Count(#ng_radio#);
void rbl_Disable(object rbl)
The function disables editing of the “Radio” control specified by the “rbl” parameter. An alternative is the general function “control_Disable”.
Example:
rbl_Disable(#ng_radio#);
void rbl_Enable(object rbl)
The function enables editing of the “Radio” control specified by the “rbl” parameter. An alternative is the general function “control_Enable”.
Example:
rbl_Enable(#ng_radio#);
void rbl_EnabledItems(object rbl, int[] items)
The function enables only the radio buttons at the indices defined by the “items” array. All others will be disabled.
Example:
rbl_EnabledItems(#ng_radio#, [0, 2]); // enables the first and third option
string rbl_SelectedItem_Text(object rbl)
The function returns the text of the selected radio button in the “rbl” group.
Example:
var s = rbl_SelectedItem_Text(#ng_radio#);
string rbl_SelectedItem_Value(object rbl)
The function returns the value of the selected radio button in the “rbl” group.
Example:
var s = rbl_SelectedItem_Value(#ng_radio#);
int rbl_SelectedIndex(object rbl)
The function returns the index of the selected item of the “Radio” control. Returns “-1” if no item is selected.
Example:
var n = rbl_SelectedIndex(#ng_radio#);
void rbl_SelectIndex(object rbl, int index)
The function selects the radio button at position “index” (from 0). A value of -1 or an empty value clears the selection.
Example:
rbl_SelectIndex(#ng_radio#, 0); // selects the first option
void rbl_SelectText(object rbl, string text)
The function selects the radio button whose text matches the “text” parameter. An empty string clears the selection.
Example:
rbl_SelectText(#ng_radio#, 'Yes');
void rbl_SelectValue(object rbl, string value)
The function selects the radio button whose value matches the “value” parameter. An empty string clears the selection.
Example:
rbl_SelectValue(#ng_radio#, '1');
class RegexFinder
A class for searching and replacing in strings using regular expressions.
- “.find(regex)” – searches for an occurrence, returns true/false
- “.value()” – returns the found text
- “.index()” – returns the position of the match
- “.replace(string)” – replaces the found text
- “.toString()” – returns the current content
Example:
var rf = new RegexFinder('Date: 1.1.2024');
if (rf.find(/\d+\.\d+\.\d{4}/)) {
alert(rf.value()); // Returns “1.1.2024”
rf.replace('20.4.2026');
}
var result = rf.toString(); // Returns “Date: 20.4.2026”
string removeDiacritics(string value)
The function replaces diacritic characters with their ASCII equivalents using a mapping table. Processes Unicode characters and surrogate pairs.
Example:
var s = removeDiacritics('Czech Republic'); // Returns “Czech Republic”
var s = removeDiacritics('Příliš žluťoučký kůň'); // Returns “Prilis zlutoucky kun”
string removeDoubleCharacters(string value, string ch)
The function removes all duplications of the character defined by the “ch” parameter from the string specified by the “value” parameter (replaces n-times repeated occurrence with a single one).
Example:
var s = removeDoubleCharacters('a b c', ' '); // Returns “a b c”
string removeDoubleLines(string value)
The function removes excess blank lines from the multiline string specified by the “value” parameter – preserves at most one consecutive blank line.
Example:
var s = removeDoubleLines('a\r\n\r\n\r\nbc'); // Returns “a\r\n\r\nbc”
string removeDoubleSpaces(string value)
The function removes double spaces from the string specified by the “value” parameter. It is an alias for “removeDoubleCharacters(value, ' ')”.
Example:
var s = removeDoubleSpaces('a b c'); // Returns “a b c”
string removeDuplicates(string value, string separator)
The function removes all duplicate items from the string specified by the “value” parameter. The item separator is defined by the “separator” parameter.
Example:
var s = removeDuplicates('aa;bb;aa;cc', ';'); // Returns “aa;bb;cc”
string removeNonAlphanumericCharacters(string value)
The function removes all characters except alphanumeric characters (a–z, A–Z, 0–9) from the string specified by the “value” parameter.
Example:
var s = removeNonAlphanumericCharacters('1:a:2'); // Returns “1a2”
string removeNonDigits(string value)
The function removes all characters except digits (0–9) from the string specified by the “value” parameter.
Example:
var s = removeNonDigits('1.2.3'); // Returns “123”
string removeTags(string value)
The function removes HTML tags from the string. Special processing:
- </div>, <br>, <hr>, </p> › \n (new line)
- <li> › \n- (list item)
- › space
Example:
var s = removeTags('<b>Bold</b> text<br>new line');
// Returns “Bold text\nnew line”
string removeTags2(string value)
The function removes all HTML tags from the string specified by the “value” parameter without any special processing (unlike “removeTags”, it does not add new lines).
Example:
var s = removeTags2('<p>abc</p><p>def</p>'); // Returns “abcdef”
string removeUnnecessarySpaces(string value)
The function removes all excess whitespace from the string – spaces and tabs at the beginning and end, and replaces double spaces inside with single spaces.
Example:
var s = removeUnnecessarySpaces(' a b c '); // Returns “a b c”
string removeWhiteSpaces(string value [, string value2])
The function removes all whitespace (spaces, tabs, newlines) from the string specified by the “value” parameter. The optional “value2” parameter specifies a replacement string (default is an empty string).
Example:
var s = removeWhiteSpaces('a b\tc'); // Returns “abc”
var s = removeWhiteSpaces('a b\tc', '-'); // Returns “a-b-c”
string replaceAll(string value, string oldValue, string newValue)
The function replaces all occurrences of “oldValue” with “newValue” in the string “value”. Does not support regular expressions – it is a direct text substitution.
Example:
var s = replaceAll('aa bb aa', 'aa', 'cc'); // Returns “cc bb cc”
void rtb_Disable(object rtb)
The function disables editing of the “RichTextBox” control specified by the “rtb” parameter. An alternative is the general function “control_Disable”.
Example:
rtb_Disable(#ng_richtextbox#);
void rtb_Enable(object rtb)
The function enables editing of the “RichTextBox” control specified by the “rtb” parameter. An alternative is the general function “control_Enable”.
Example:
rtb_Enable(#ng_richtextbox#);
void rtb_Focus(object rtb)
The function sets the focus to the “RichTextBox” control defined by the “rtb” parameter.
Example:
rtb_Focus(#ng_richtextbox#);
void rtb_Insert(object rtb, string value)
The function inserts the value specified by the “value” parameter at the current cursor position into the “RichTextBox” control.
Example:
rtb_Insert(#ng_richtextbox#, 'Inserted text');
void scroll_Save(object hfx, object hfy, int viewpage, string s)
The function saves the current scroll position to the hidden fields “hfx” and “hfy”. If “viewpage” is non-zero, it asynchronously saves the position to the server (page “SaveContext.aspx”) after 1 second. The “s” parameter is a context identifier.
Example:
scroll_Save(el('ng-scrollx'), el('ng-scrolly'), 0, '');
void scroll_To(int x, int y [, bool save])
The function scrolls the page or scroll container to position (x, y). If the “save=true” parameter is set, the position is stored in hidden fields for preservation after a postback.
Example:
scroll_To(0, 500);
scroll_To(0, 0, true);
int scrollLeft2([object o])
The function returns the current horizontal scroll position of the window or element “o”. Works correctly in RTL mode and across different browsers. If a custom scroll container (“ScrollContainer”) is available, it uses it.
Example:
var n = scrollLeft2();
int scrollTop2([object o])
The function returns the current vertical scroll position of the window or element “o”. Works correctly across different browsers. If a custom scroll container (“ScrollContainer”) is available, it uses it.
Example:
var n = scrollTop2();
void setStyleLeft(object o, string value [, bool ltr])
The function sets the “style.left” or “style.right” property of element “o” depending on the current text direction (LTR/RTL). The optional “ltr” parameter overrides the automatic direction detection.
Example:
setStyleLeft(el('ng-element'), '100px');
void setStyleMarginLeft(object o, string value)
The function sets “style.marginLeft” (LTR) or “style.marginRight” (RTL) of element “o” depending on the current text direction.
Example:
setStyleMarginLeft(el('ng-element'), '10px');
void setStyleMarginRight(object o, string value)
The function sets “style.marginRight” (LTR) or “style.marginLeft” (RTL) of element “o” depending on the current text direction.
Example:
setStyleMarginRight(el('ng-element'), '10px');
void setStylePaddingLeft(object o, string value)
The function sets “style.paddingLeft” (LTR) or “style.paddingRight” (RTL) of element “o” depending on the current text direction.
Example:
setStylePaddingLeft(el('ng-element'), '5px');
void setStylePaddingRight(object o, string value)
The function sets “style.paddingRight” (LTR) or “style.paddingLeft” (RTL) of element “o” depending on the current text direction.
Example:
setStylePaddingRight(el('ng-element'), '5px');
void setTimeout2(object o, function f [, int timeout])
A debounce helper function – cancels the previous timeout stored in object “o” and sets a new one with function “f” and waiting time “timeout” ms (default 0). Suitable for deferred event processing (e.g. keyup in a textbox).
Example:
// Called on every keypress, but processing happens only after 300ms of silence
attachEvent2(#ng_textbox#, 'keyup', function() {
setTimeout2(#ng_textbox#, function() {
// text processing
}, 300);
});
string Str2Date(string text [, Date defvalue])
The function parses a text string into a Date object. Supports formats “dd.MM.yyyy HH:mm” and “mm/dd/yyyy HH:mm”. Two-digit years are converted by adding 2000 (e.g. “25” returns 2025). On parsing error, returns “defvalue” or “new Date()”.
Example:
var d = Str2Date('1.1.2024');
var d = Str2Date('1.1.2024 12:30');
var d = Str2Date('invalid date', new Date(2000, 0, 1));
class StringBuilder
A class for efficient string building. Methods:
- “.append(value)” – appends a value to the end
- “.appendLine(value)” – appends a value + \n
- “.clear()” – clears the content
- “.isEmpty()” – returns true if the content is empty
- “.toString()” – returns the assembled string
Example:
var sb = new StringBuilder();
sb.append('Hello');
sb.append(', ');
sb.append('World');
var s = sb.toString(); // Returns “Hello, World”
class StringFinder
A class for searching and replacing substrings.
- “.find(string)” – finds an occurrence, returns true/false
- “.replace(string, length)” – replaces the found text, optional “length” parameter is the replacement length
- “.toString()” – returns the current content
Example:
var sf = new StringFinder('Hello World');
if (sf.find('World')) {
sf.replace('NET Genium');
}
var s = sf.toString(); // Returns “Hello NET Genium”
void ta_Disable(object ta)
The function disables editing of the “TextArea” control specified by the “ta” parameter. An alternative is the general function “control_Disable”.
Example:
ta_Disable(#ng_textarea#);
void ta_Enable(object ta)
The function enables editing of the “TextArea” control specified by the “ta” parameter. An alternative is the general function “control_Enable”.
Example:
ta_Enable(#ng_textarea#);
void ta_Insert(object ta, string value)
The function inserts the value “value” at the current cursor position into the “TextArea” control specified by the “ta” parameter.
Example:
ta_Insert(#ng_textarea#, 'Inserted text');
void tab_Disable(int n)
The function disables (grays out) the tab with index “n” in the form's tab system.
Example:
tab_Disable(2); // disables the third tab (indexed from 0)
void tab_Enable(int n)
The function enables the tab with index “n” in the form's tab system.
Example:
tab_Enable(2);
int tab_GetValue()
The function returns the index of the currently active tab.
Example:
var n = tab_GetValue(); // Returns 0, 1, 2, ...
void tab_Open(int n)
The function programmatically switches to the tab with index “n”.
Example:
tab_Open(1); // switches to the second tab
void tab_SetValue(int n)
The function sets the value of the hidden tab field to “n” without visual switching.
Example:
tab_SetValue(2);
void tb_Disable(object tb)
The function disables editing of the “TextBox” control specified by the “tb” parameter. An alternative is the general function “control_Disable”.
Example:
tb_Disable(#ng_textbox#);
void tb_Enable(object tb)
The function enables editing of the “TextBox” control specified by the “tb” parameter. An alternative is the general function “control_Enable”.
Example:
tb_Enable(#ng_textbox#);
void tb_InitAjax(object tb, function f, int width, int left, bool focus)
The function initializes a custom ajax picker for the text field “tb”. The “f” parameter is the function called on keyup (and on focus if “focus=true”). The “width” parameter specifies the width of the picker window in pixels. The “left” parameter is the horizontal offset of the picker window from the control. The “focus” parameter determines whether the picker is displayed when clicking on the field (“true”) or when typing (“false”).
Example:
tb_InitAjax(#ng_tb#, function(e) { startSearch(e, 'test'); }, 150, 0, false);
function startSearch(e, p0)
{
tb_LoadUrl(e, 'TestPicker.aspx?' + urlEncode(#ng_tb#.value));
}
int Time2Int(string text)
The function converts a text string – time in the format “HH:mm” – to a number of minutes. Correctly handles negative values.
Example:
var n = Time2Int('01:23'); // Returns 83
var n = Time2Int('-01:24'); // Returns -84
var n = Time2Int('00:00'); // Returns 0
string translate(string language, string value [, string language2])
The function returns the translated text from a multilingual string. Format of “value”: “#cs:Czech#en:English#de:German”. The optional “language2” parameter overrides “language”. If the translation is not found, returns the first value or the entire string.
Example:
var s = translate('cs', '#cs:Hello#en:Hello#de:Hallo'); // Returns “Hello”
var s = translate('fr', '#cs:Ahoj#en:Hello'); // Returns “Ahoj” (fallback)
string urlDecode(string value)
The function decodes a URL-encoded string. Supports special characters and Czech/Slovak diacritics (encoded as %xx sequences).
Example:
var s = urlDecode('%c4%8desk%c3%a1'); // Returns “česká”
string urlEncode(string value)
The function encodes a string for use in a URL. Supports special characters and Czech/Slovak diacritics. Not identical to native encodeURIComponent – uses its own mapping table.
Example:
var s = urlEncode('česká republika'); // Returns “%c4%8desk%c3%a1%20republika”
_loadUrl(new Object(), 'ngef.aspx?MyFunction,' + urlEncode(param));
string ZInt(int n)
The function pads a number to a minimum of 2 digits with a leading zero. Used for formatting time and date.
Example:
var s = ZInt(5); // Returns “05”
var s = ZInt(12); // Returns “12”
string ZInt4(int n)
The function pads a number to a minimum of 4 digits with leading zeros. Used for formatting the year.
Example:
var s = ZInt4(42); // Returns “0042”
var s = ZInt4(2024); // Returns “2024”