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”),
- from the button next to a text field or a foreign key, from the JavaScript of the “Save”, “Delete” and “Back” buttons and from the default value of a text field of the JavaScript type,
- from the <script> tag in the “HTML” and “RichText” controls.
- 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 the values of controls at the time the edit form is rendered via identifiers – “#ng_:value#”. The value is inserted by the server (the stored value, the default value or the value submitted by the form); it is not the live value in the browser, which is returned by the “control_GetValue(#ng_#)” function,
- 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#)”.
- Variables, server functions and external functions are evaluated by the server once, when the page is rendered – only their result reaches the browser. A function whose name matches the name of a server function (e.g. “function lower(s)”) is also evaluated by the server; custom JavaScript functions should therefore not be named this way.
- Inserted values are put into the code without escaping. Text entered by a user (a control value, the result of the “SQL” function, the login name) can therefore break the code inside a '...' string or change its meaning – only values whose content is under control should be inserted into the code, and texts entered by users should be read in the browser by the “control_GetValue” function.
- When rendering, NET Genium rewrites the “alert(” and “confirm(” calls in the code to its own “alert2(” and “confirm2(” functions, which remove HTML tags from the text, and the “translate(” call to a version extended with the language of the user. The rewrite applies only to a call that is not preceded by a letter, digit, underscore, period or the “$” character (for “translate(” also not by a quotation mark, an apostrophe or a hyphen); in addition, “translate(” is not rewritten in a “transform:” CSS declaration (e.g. “transform: translate(10px, 5px)”).
- 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#); on a view page its value is 0
- sID – text representation of nID (string); not defined on a view page
- Page_IsPostBack – The page is loaded after a postback; the variable is available in the edit form and on the view page and reflects the first load of the page or a classic form submit, not an ajax update
- dateSeparator – Date separator (usually “.”)
- numberSeparator – Decimal separator (usually “,”)
- dialogYes – Label of the affirmative dialog button in the language of the signed-in user (usually “Yes”), intended for the “jsConfirm” and “jsDialog” functions
- dialogNo – Label of the negative dialog button in the language of the signed-in user (usually “No”), intended for the “jsConfirm” and “jsDialog” functions
- 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 in the request body using the POST method (format: key=value&key2=value2). The POST method is used whenever “params” is not “null”, i.e. also for an empty string. The “f” callback is called only for a response with HTTP status 200, with the parameters (html, id, headers).
The “ngef.aspx” page does not pass the values from the request body to the “args” array – the external function reads them with the “conn.Page.Form("p0")” method. The parameters in the URL after the question mark are first decoded as a whole and only then split on commas, so a value containing a comma belongs to “params”. An unauthorized call of an external function returns the text “UNAUTHORIZED” (with status 200).
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)
Extension of the previous variant with the “errorMessage” parameter. If the server returns an HTTP status other than 200, a dialog with the “errorMessage” text is displayed to the user. The “errorMessage” parameter can also be a function, which is called in that case.
Example:
_loadUrl(new Object(), 'ngef.aspx?MyFunction', ajaxResponse, null, null, 'Error loading data.');
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. On a page without a form the function refreshes the page instead of clicking.
Example:
bt_Click();
void bt_Click(string id)
The function performs a programmatic click on the button specified by the “id” parameter. The function first tries to find the element with the given ID, and if it does not find it, then with the given text. Internally it uses the “_bt_Click” flag to prevent a double click: only one postback can be triggered from JavaScript at a time, and further calls of the “bt_Click” function are silently ignored until the page processes the first one.
Example:
bt_Click(BT123);
bt_Click('Save');
void bt_Click(string id, string name, string value)
Extension of the previous variant. Before clicking the button, it inserts a hidden field named “name” with the value “value” into the form. It allows an additional parameter to be passed in the postback. The names “action” and “action-submit” are reserved for the NET Genium postback – a hidden field with such a name would invalidate the button click.
Example:
bt_Click(BT123, 'operation', '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”
void 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. The parameter is the ID of the button; the function ignores a passed element.
Example:
button_Disable(BT123);
void button_Enable(o)
The function enables the button specified by the “o” parameter in the edit form. The parameter is the ID of the button; the function ignores a passed element.
Example:
button_Enable(BT123);
void buttons_Disable()
The function disables all buttons of the “Button” type in the edit form. The “Save”, “Delete” and “Back” buttons remain unchanged.
Example:
buttons_Disable();
void buttons_Enable()
The function enables all buttons of the “Button” type in the edit form. The “Save”, “Delete” and “Back” buttons remain unchanged.
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. In admin mode the function does nothing, so that all controls remain visible.
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 the hexadecimal format “#rrggbb”. The function can process:
- The “R,G,B” format (e.g. “255,0,0” returns “#ff0000”)
- A 6-digit hex without # (e.g. “ff0000” returns “#ff0000”)
- A string of 7 characters, which is returned unchanged – the “#rrggbb” notation is assumed and the format is not validated
- The prefixes “B”, “I”, “BI”, “IB”, “N” are automatically removed before processing
- A conditional color format by date: “color@date1@color1@date2@color2” – returns the color according to 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('255,128', '#000000'); // Returns “#000000”
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 saves the value of a database control to the database using ajax. The “OnBeforeSave” and “OnAfterSave” events are not run and the controls are not validated; only the default values of controls with the option “Fill in the default value before each saving of the record to the database” are filled in. For a new record that has not yet been saved, the function instead saves the whole edit form in the usual way – including validation and the “OnBeforeSave” and “OnAfterSave” events.
Saving works only if the “control_Save” call is written literally in the JavaScript or in the events of controls of the given edit form and the form is not locked against editing; otherwise the server refuses it.
Example:
control_Save(#ng_control#);
void control_Save(object o, string f, string errorMessage)
The function saves the value of a database control to the database using ajax. The “f” parameter is a callback called after the server response with the text “OK”, or “ERROR” followed by the error message on the next line. The “errorMessage” parameter defines the text of the message displayed if the server responds with an HTTP status other than 200. For a new record that has not yet been saved, the whole form is saved and the “f” callback is not called.
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 validation or DatePicker: “value” can be a string “dd.MM.yyyy HH:mm” or a Date object. The optional “value2” is the time “HH:mm” (only for a TextBox with time).
- “CheckBox”: if “value” is a boolean, it sets the check directly. If it is a string, it is compared with the “chv” attribute.
- “ForeignKey”: sets the record ID; the value 0 also clears the displayed text, another value does not change the displayed text – that is refreshed by the “fk_Update” function.
- “DatePicker”, “RichTextBox” and “MultiListBox”: the “onchange” event is fired after setting.
- “MultiListBox”: “value” are IDs separated by a semicolon or a tab and “value2” is an array of [id, text] pairs used to convert the IDs to texts.
- “TextBox”, “ComboBox” and “ListBox”: the “onchange” event is not fired.
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)
The function joins the controls defined by the “array” parameter into a group in which all controls up to the last filled one plus one more are visible – empty controls between filled ones remain visible. The value “0” is treated as empty. The function also attaches the “change” event to the controls, so the group is redrawn automatically whenever a value changes; it is therefore enough to call it once when the form is loaded. The second parameter of the function is reserved for internal use and is not specified.
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 saves the values of database controls to the database using ajax. The “OnBeforeSave” and “OnAfterSave” events are not run and the controls are not validated; only the default values of controls with the option “Fill in the default value before each saving of the record to the database” are filled in. For a new record that has not yet been saved, the whole edit form is saved in the usual way. As with the “control_Save” function, the call must be written literally in the JavaScript or in the events of controls of the given form.
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 saves the values of database controls to the database using ajax. The “f” parameter is a callback called with the text “OK”, or “ERROR” followed by the error message on the next line. The “errorMessage” parameter defines the text of the message displayed if the server responds with an HTTP status other than 200.
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 sets a browser cookie using an AJAX call to the “SaveCookie.aspx” page, which sends the cookie in the server response. The result is a regular browser cookie valid for 6 months, which can be read by the “cookie_Get” function and by server code. The function accepts the optional parameters “f” (callback), “id” and “errorMessage” in the same way as the “_loadUrl” function. A cookie whose name starts with the text “SessionGuid_” or “ASP.NET_” is not set by the function – these cookies belong to the user's login.
Example:
cookie_Set('TestCookie', 'Test cookie');
bool copyToClipboard(string value, string info [, object e])
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 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 in the date format set in NET Genium (order of day and month and the separator). Day and month are padded with a zero to two digits. If the time is 00:00, it returns only the date; otherwise the date and the time “HH:mm”.
Example:
var s = Date2Str(new Date());
var s = Date2Str(new Date(2000, 0, 1)); // Returns “01.01.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');
}
bool dg_ColumnWidth(object dg, int cid, int width)
The function sets the width of the “cid” column in the “dg” datagrid to the value “width”. A numeric value is taken in pixels; a text with a unit can also be specified (e.g. “20%”). It returns “true” if it found the column.
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 bulk editing in all datagrids. The function affects all form fields on the page that have neither an ID nor a name, and also hides the links for opening a record.
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 bulk editing in all datagrids. The function affects all form fields on the page that have neither an ID nor a name, and also shows the links for opening a record.
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 “dg” datagrid using AJAX. The optional “f” parameter is a callback called after loading has finished. The function is converted to text, so it has no access to the local variables of the calling code. If the page contains JavaScript that modifies the DOM of the datagrid, the datagrid is loaded by submitting the whole page.
Example:
dg_Update(DG123);
dg_Update(DG123, function() { alert('The 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#);
void dragWindow_Down(object o, object e [, int width, int height, function onMove, function onUp])
The function starts moving an element with a mouse or touch gesture. It stores the initial coordinates, creates an auxiliary drag window, and attaches the movement and completion handlers specified by “onMove” and “onUp”.
void dragWindow_Move(object e, int threshold [, function callback, bool allowTextSelection])
The function processes movement of the currently dragged element. Dragging starts after the distance specified by “threshold” is exceeded, and the optional “callback” receives the dragged object and current coordinates.
void dragWindow_Up(object e [, function onDrop, function onClick])
The function ends the current drag operation, detaches event handlers, and hides the auxiliary window. It calls “onDrop” after an actual move, or “onClick” when no move occurred.
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. It is written into the client event of a button and is used with the Invisible variant, that is, together with the “GOOGLECAPTCHAINVISIBLE” server function. The implementation procedure is provided in the separate guide Google reCAPTCHA implementation.
Example:
evalGoogleCaptcha();
void file_Disable(object file)
The function disables editing of the “File” control. For this control it means the “Browse...” button for inserting a new file is hidden (together with the delete button and any picker dialog); a file that has already been inserted remains shown as a download link. An alternative is the general function “control_Disable”.
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 calls the handler of the “type” event on the “o” object. Outside Internet Explorer only the handler written in the “on” + “type” property (the “onchange”, “onclick” attribute etc.) is called; listeners added by the “attachEvent2” or “addEventListener” functions are not run.
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 values of the form controls to the database using AJAX to the “Save.aspx” page. The optional “f” parameter is a callback called after the server response with the text “OK”, or “ERROR” followed by the error message. The flag of unsaved changes is cleared immediately after sending; if saving ends with an error, the form is marked as changed again. The “OnBeforeSave” and “OnAfterSave” events are not run and the controls are not validated. For a new record that has not yet been saved, the function instead saves the edit form in the usual way – including validation and both events. As with the “control_Save” function, the call must be written literally in the JavaScript or in the events of controls of the given form.
Example:
form_Save();
form_Save(function(html) { alert(html); });
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 hexadecimal string (lower case). If the result has one character, it is padded with a zero at the beginning; a longer result is not shortened.
Example:
var s = Hex(123); // Returns “7b”
var s = Hex(15); // Returns “0f”
var s = Hex(255); // Returns “ff”
var s = Hex(256); // Returns “100”
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. This hides the “Browse...” button for inserting a new image (together with the delete button and any picker dialog); an image that has already been inserted remains displayed. 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();
string innerText2(object o [, string value])
Without “value”, the function returns the text content of element “o”. When “value” is provided, it sets the text content. It normalizes differences between the “innerText” and “textContent” properties in supported browsers.
Example:
var text = innerText2(#ng_description:Name#);
innerText2(#ng_description:Name#, 'New title');
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 “HH:mm” format into the text field defined by the “tb” parameter. Neither the “onchange” event nor the form change flag is triggered.
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 the total number of minutes to a time in the “HH:mm” format with the hours padded with a zero to two digits. It handles negative values correctly.
Example:
var s = Int2Time(90); // Returns “01:30”
var s = Int2Time(-15); // Returns “-00:15”
var s = Int2Time(0); // Returns “00:00”
bool isImage(string filename)
The function returns “true” if the file name has an image extension: bmp, dib, emf, gif, ico, jfif, jpe, jpeg, jpg, png, rle, svg, tif, tiff or wmf. The “webp” extension is not among them.
Example:
var b = isImage('photo.jpg'); // Returns true
var b = isImage('document.pdf'); // Returns false
void jsAlert(string html[, function f])
The function displays a message in a modal dialog with an “OK” button (it does not use the native browser “alert”, so it does not halt the execution of the following code). The “html” parameter is the content of the message and may contain HTML tags. The optional “f” parameter is a function executed after the “OK” button is clicked — everything that is supposed to follow only after the message has been acknowledged belongs in it, not after the “jsAlert” call.
Example:
jsAlert('The record has been saved.');
jsAlert('The record has been saved.', function() { jsRefresh(window); });
void jsClose([string message])
The function closes the current iframe dialog, or the window if the page is not opened as a dialog. If the optional “message” parameter is filled in, the function first displays the message using “jsAlert” and performs the closing only after it is acknowledged with the “OK” button.
Example:
jsClose();
jsClose('OK');
string jsCompanyWithoutSro(string value)
The function shortens the company name before the first occurrence of a space followed by an abbreviation of a Czech legal form – “ a.”, “ k.”, “ kom.”, “ s.”, “ spol.” or “ v.” (case-insensitive) – and returns the text before it. A legal form at the beginning of the name is not removed. Because the function looks only for the listed beginnings, it also shortens a name in which such a combination appears in the middle (e.g. “Jan K. Novák” returns “Jan”), and a comma before the legal form is kept.
Example:
var s = jsCompanyWithoutSro('ABC s.r.o.'); // Returns “ABC”
var s = jsCompanyWithoutSro('XYZ a.s.'); // Returns “XYZ”
bool jsConfirm(object o, string html[, string yes, string no[, function f]])
The function displays a confirmation question over the “o” element and returns “true” only once the user has answered affirmatively — it is the replacement of the native “confirm” in a click handler. The “o” parameter is the element that was clicked (usually “this”), “html” is the text of the question, and “yes” and “no” are the labels of the two buttons — for “Yes” and “No”, the “dialogYes” and “dialogNo” variables are passed, which follow the language of the signed-in user; omitted labels are filled in from exactly these variables. The optional “f” parameter is a function executed after a negative answer (inside it, “this” refers to the “o” element).
It is written the same way as the native “confirm”:
if (!jsConfirm(this, 'Do you really want to delete the record?', dialogYes, dialogNo)) return false;
The dialog does not halt the execution of the code, so on the first click the function only displays the question and returns “false”. An affirmative answer then clicks the element again and the function returns “true” the second time — which sets off the default action of the element, that is submitting the form or the script of the button.
Two limitations follow from that. The click handler is executed again after every affirmative answer, so anything in front of the question is performed repeatedly — only checks without side effects may stand in front of it. And the “o” element has to be clickable (a button or a link). Confirming something other than a click, for example a change of the value in a select box (“onchange”), is handled by the “jsDialog” function, with the continuation written into its function.
One click handler may ask about several things in turn. The function remembers every confirmed question until the handler runs all the way through again after an affirmative answer; on the next pass it therefore returns “true” for all questions already confirmed and asks only the following one. A question is recognized by its “html” text, so the text has to be the same on every pass. A negative answer to any of the questions ends the whole sequence.
The “o” element may be omitted (pass “null”) — the function then uses the element that has just been clicked; if the call does not run in the handler of any event (for example from “setTimeout”), it returns “false” and displays no question. This makes it possible to call it even from a function run by the “Save” or “Delete” button of an edit form, which does not receive the button itself:
function beforeSave()
{
if (!jsConfirm(null, 'Do you really want to save the changes?')) return false;
if (!jsConfirm(null, 'Do you really want to continue?')) return false;
return true;
}
string jsDialog(string html, object[] buttons[, object context])
The function displays a modal confirmation dialog (it does not use the native browser “confirm”, so it does not halt the execution of the following code and does not return the answer of the user). The “html” parameter is the dialog content and may contain HTML tags. Returns the dialog ID.
The answer is not returned as a return value — whatever is supposed to happen after the answer belongs in the function passed to the dialog. The “buttons” parameter is an array in the form “[label1, function1, label2, function2, ...]”, where every pair is one button of the dialog; a function may be “null”, in which case the button only closes the dialog. The labels are given at every call, because they follow the language of the signed-in user; the “dialogYes” and “dialogNo” variables serve for “Yes” and “No”.
The optional “context” parameter determines what “this” refers to inside the passed functions — usually “this” from the click handler is passed, so that the function can work with the button that opened the dialog.
In a click handler, the call always has to be followed by “return false” — the dialog opens asynchronously, so the default action of the element (submitting the form, following the link) has to be cancelled; the actual action is performed later from the passed function.
An empty button array (“[]”) creates a dialog without buttons — a blocking overlay that the user cannot close. It serves as a “Please wait” message for the duration of a long operation; it is closed only from code, by the “jsDialogClose” function with the ID that “jsDialog” returned.
Only one dialog may be open at a time. If one is already displayed, another call of “jsDialog” — and therefore of “jsAlert” as well — displays nothing and returns “null”, so the message is silently discarded. A blocking overlay therefore always has to be closed before the next dialog.
The second case in which the function returns “null” is a dialog raised while the page is still loading — it is displayed only after the page has loaded, because until then the page is covered by the loader. This does not apply to a blocking overlay without buttons: that one is displayed immediately and returns the ID, so that there is something to close it with.
Example:
jsDialog('Really delete?', [dialogYes, function() { bt_Click(BT123); }, dialogNo, null], this); return false;
jsDialog('Save the changes?', [
'Save', function() { bt_Click(BT123); },
'Discard', function() { jsClose(); },
'Back', null
]); return false;
var id = jsDialog('Please wait...', []);
_loadUrl(new Object(), 'ngef.aspx?MyFirstFunction', function(html) { jsDialogClose(id); jsAlert(html); });
void jsDialogClose(string id)
The function closes a dialog opened by the “jsDialog” function. The “id” parameter is the dialog ID that “jsDialog” returned; a nonexistent ID is ignored.
It serves to close a dialog without buttons — the user cannot close that one, so it has to be closed from code. A dialog with buttons closes itself after a click and this function does not need to be called for it.
Example:
var id = jsDialog('Please wait...', []);
_loadUrl(new Object(), 'ngef.aspx?MyFirstFunction', function(html) { jsDialogClose(id); jsAlert(html); });
string jsDisplay(bool value)
The function returns an empty string (visible) if “value” is true, or the string “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 thousands separators and a decimal separator according to the language of the currently logged-in user (Czech: a space and a comma; English: a comma and a period). It pads the number to at least 2 decimal places; a longer decimal part is neither rounded nor shortened. The optional “symbol” parameter is added after the number.
Example:
var s = jsFormatCurrency(1234567.89, 'CZK'); // Returns “1,234,567.89 CZK” (in Czech “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 the thousands and decimal separators of the language of the currently logged in user (English: comma and period; Czech: space and comma). 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” (in Czech “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(object[][] value, string title, int width, bool showGrid, string noEntries, int pageSize, object tb_pageIndex)
The function renders the complete HTML of a datagrid from tabular data. The “value” parameter is a two-dimensional array: “value[0]” is the header row and the other elements are data rows whose elements are the cell values. A cell with the value “null” (the JavaScript value, not text) causes a colspan of the neighboring column. The alignment of a column is determined in the header: prefix | = left, suffix | = right, prefix and suffix | = center. Column width: suffix ! = width in pixels. Paging is provided by the “pageSize” parameter and the “tb_pageIndex” parameter, which is the text field with the number of the current page. Cell values and the title are inserted as HTML without changes – data entered by the user must therefore be encoded beforehand by the “htmlEncode” function.
Example:
var data = 'Age'], ['John', '30'], ['Petra', '25';
var html = jsFormatTable(data, 'Overview', 500, true, 'No entries', 10, null);
el('ng-output').innerHTML = html;
string jsFormatTable2(object[][] value, int width, string noEntries)
A simplified version of “jsFormatTable” without a grid and with minimal formatting. The “value” parameter has the same form as for the “jsFormatTable” function.
Example:
var html = jsFormatTable2('Age'], ['John', '30', 400, 'No entries');
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”
string jsFullName(object title, object name, object surname [, object title2])
The function builds a full name from the values of controls containing a title before the name, first name, surname, and an optional title after the name. Empty parts are omitted and the trailing title is separated by a comma.
Example:
#ng_fullname#.value = jsFullName(#ng_titlebefore#, #ng_firstname#, #ng_surname#, #ng_titleafter#);
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. An empty string or a string containing only spaces is evaluated as a number.
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. It handles a comma as the decimal separator (only the first comma is replaced). It returns 0 for null, an empty string, text that is not a number (e.g. with a space between thousands) or values outside the range ±1,000,000,000,000. The optional “o2” parameter is added as the decimal part.
Example:
var n = jsN('1234,56'); // Returns 1234.56
var n = jsN('1 234,56'); // Returns 0 (a space is not allowed)
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 Czech VAT rates separated by a semicolon, from the highest to the zero rate.
Example:
var s = jsngdph();
// Returns the current Czech VAT rates, e.g. “21;12;0”
double jsngdph(int rate)
The function returns the current Czech VAT rate according to the index specified by the “rate” parameter: 2 = standard rate, 1 = first reduced rate, 3 = second reduced rate, 0 = zero rate. If the rate does not apply at the given date, it returns 0.
Example:
var n = jsngdph(2);
// Returns the standard VAT rate, e.g. 21
var n = jsngdph(1);
// Returns the reduced VAT rate, e.g. 12
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 calculated so that the amount including VAT is rounded up to a whole number
- “dph1” – VAT of the reduced rate
- “zdph1” – VAT of the reduced rate calculated so that the amount including VAT is rounded up
- “dph2” – VAT of the increased rate
- “zdph2” – VAT of the increased rate calculated so that the amount including VAT is rounded up
- “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
number[] 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 at the date specified by the “date” parameter. The values are sorted from the highest rate to the lowest. An empty country code or “-” means the Czech Republic; Greece can be specified by the code “GR” or “EL”; for an unknown country it returns “null”.
Example:
var rates = jsngvatrates('CZ', new Date()); // Returns e.g. [21, 12]
var rates = jsngvatrates('DE', Str2Date('1.1.2013')); // Returns [19, 7]
number jsNumber(var o [, var o2])
Alias for the “jsN” function. It safely converts a value to a number. It handles a comma as the decimal separator.
Example:
var n = jsNumber('1234,56'); // Returns 1234.56
var n = jsNumber(null); // Returns 0
string jsNumberInWords(number n, string language)
The function converts a number to its text form in words. Supported languages: “cz”/“cs” (Czech), “sk” (Slovak), “de” (German), “en” (English), “fr” (French). It supports values up to billions. The number is rounded to an integer before conversion and the sign is ignored.
Example:
var s = jsNumberInWords(1234, 'cz'); // Returns “jeden 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');
bool jsPost([string action, function f, bool loader])
The function sends all form values using the POST method to the current URL of the page. The “action” parameter is the name of the action that the page processes (not an address). The optional “f” parameter is a callback to which the HTML of the response is passed – it is called for a partial response and for a response with the whole page. The “loader” parameter with the value “true” shows the loading indicator immediately, otherwise it appears after one second. The function processes the navigation headers of the response for redirection and returns “false”.
Example:
jsPost();
jsPost(null, function(html) { alert('Done'); });
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 – a positive number in pixels, or a CSS length in the units “px”, “%”, “em”, “rem” or “vw” (e.g. “50%”); any other value is ignored and the progress bar has no width. The “done” parameter 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 hellers (i.e. to multiples of 0.5). The number is first rounded to 2 decimal places; a decimal part below 0.25 is rounded down, from 0.25 to 0.75 to 0.5 and from 0.75 up. 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 124
var n = jsR_50(123.750); // Returns 124
var n = jsR_50(123.249); // Returns 123.5
var n = jsR_50(123.240); // Returns 123
void jsRefresh(object o [, bool refresh, string id, string cmd])
The function refreshes the page in the window specified by the “o” parameter while keeping the scroll position and the state of tabs. The “o” parameter is mandatory – typically “window” or the window of a frame. The page is reloaded using the GET method, so unsaved form values are lost. The value “update” of the “cmd” parameter clicks the “btUpdate” button instead of refreshing.
Example:
jsRefresh(window);
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 usergroup)
The function checks whether the currently logged in user is a member of the specified user group. Uses the global “usergroups” array, which contains both the IDs and the names of the logged-in user's groups. The parameter can be either the group ID or its name.
The group ID is preferred — the ID never changes, whereas the group name can be renamed (and may differ by language), so checking by name is more fragile.
Example (preferred, by group ID):
if (jsUserInGroup(1)) {
// ...
}
Example (by group name):
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);
bool jsWait([string url, bool _pleaseWait, object _window, string errorMessage])
The function shows the loading indicator and navigates to the given URL. Without the “url” parameter it only shows the loading indicator. The “_window” parameter specifies the target window. The “_pleaseWait” parameter is not used. The “errorMessage” parameter applies only on devices with Windows CE, where the availability of the server is checked before navigating. The function always returns “false”.
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 in the request body using the POST method (format: key=value&key2=value2). The POST method is used whenever “params” is not “null”, i.e. also for an empty string. The optional fifth parameter “errorMessage” defines the text of the message displayed for an HTTP status other than 200; unlike the “_loadUrl” function, it cannot be specified as a function.
The “ngef.aspx” page does not pass the values from the request body to the “args” array – the external function reads them with the “conn.Page.Form("p0")” method.
Example:
loadUrl('ngef.aspx?MyFirstFunction', ajaxResponse, 'test', 'p0=' + urlEncode(p0) + '&p1=' + urlEncode(p1));
function ajaxResponse(html, id)
{
alert(id + ': ' + html);
}
bool loginByFacebook(string scope, bool offline)
The function checks whether the user is logged in to a Facebook account with a valid token. If so, it returns “true”. If not, it opens the Facebook login in a new browser window with the permission scope “scope” and returns “false”. A successful login sets the value of the “#facebook_access_token#” variable.
Example:
if (loginByFacebook('email', false))
{
// the token is valid
}
bool loginByGoogle(string scope, bool offline)
The function checks whether the user is logged in to a Google account with a valid token. If so, it returns “true”. If not, it opens the Google login in a new browser window with the permission scope “scope” and returns “false”. A successful login sets the “#google_access_token#” variable. The “offline=true” parameter also sets “#google_refresh_token#”.
Example:
var ok = loginByGoogle('https://www.googleapis.com/auth/youtube', false);
bool loginByMicrosoft(string scope, bool offline)
The function checks whether the user is logged in to a Microsoft account with a valid token. If so, it returns “true”. If not, it opens the Microsoft login in a new browser window with the permission scope “scope” and returns “false”. A successful login sets the “#microsoft_access_token#” variable. The “offline=true” parameter also sets “#microsoft_refresh_token#”.
Example:
var ok = loginByMicrosoft('openid email', false);
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 “lb” list of the “MultiListBox” control. The parameter is the inner list of the control – the element with the ID “<id>_lb1” (offer) or “<id>_lb2” (selected items), not the “#ng_multilistbox#” variable, which refers to the hidden field with the value. The function does not change the stored value of the control and does not fire the “onchange” event. After removal it selects the nearest remaining item. On a mobile device the lists do not exist.
Example:
mlb_Items_Delete(el('#ng_multilistbox:id#_lb2'));
string mlb_Items_JoinTexts(object lb)
The function returns the texts of all items of the “lb” list of the “MultiListBox” control joined by the separator “[*VS*]”. The parameter is the inner list of the control (“<id>_lb1” or “<id>_lb2”), see the “mlb_Items_Delete” function.
Example:
var s = mlb_Items_JoinTexts(el('#ng_multilistbox:id#_lb2'));
string mlb_Items_JoinValues(object lb)
The function returns the values of all items of the “lb” list of the “MultiListBox” control joined by the separator “[*VS*]”. The parameter is the inner list of the control (“<id>_lb1” or “<id>_lb2”), see the “mlb_Items_Delete” function.
Example:
var s = mlb_Items_JoinValues(el('#ng_multilistbox:id#_lb2'));
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 “lb” list of the “MultiListBox” control one position down. The parameter is the inner list of the control (“<id>_lb2”), see the “mlb_Items_Delete” function.
Example:
mlb_Items_MoveDown(el('#ng_multilistbox:id#_lb2'));
void mlb_Items_MoveUp(object lb)
The function moves the selected item in the “lb” list of the “MultiListBox” control one position up. The parameter is the inner list of the control (“<id>_lb2”), see the “mlb_Items_Delete” function.
Example:
mlb_Items_MoveUp(el('#ng_multilistbox:id#_lb2'));
string Now()
The function returns the current date and time “HH:mm” in the date format set in NET Genium; day and month are padded with a zero to two digits. The date and time follow the time zone in which the user sees times in NET Genium (the user's own time zone, otherwise the NET Genium time zone), not the clock of the user's computer.
Example:
var s = Now(); // Returns e.g. “20.04.2026 14:35”
string Now2()
The function returns the current date and time “HH:mm:ss” (including seconds) in the date format set in NET Genium; day and month are padded with a zero to two digits. The date and time follow the time zone in which the user sees times in NET Genium (the user's own time zone, otherwise the NET Genium time zone), not the clock of the user's computer.
Example:
var s = Now2(); // Returns e.g. “20.04.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, string[] items)
The function enables only the radio buttons whose value is listed in the “items” array. The others are disabled.
Example:
rbl_EnabledItems(#ng_radio#, ['Yes', 'No']); // enables only the “Yes” and “No” options
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#);
bool rbl_SelectIndex(object rbl, int index)
The function selects the radio button at the position “index” (from 0) and returns “true”. It ignores a non-existent position (including -1) and returns “false” – the selection is not cleared. The “onchange” event is not fired.
Example:
rbl_SelectIndex(#ng_radio#, 0); // selects the first option
bool 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');
bool 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');
string removeDiacritics(string value)
The function replaces characters with diacritics by their ASCII equivalents using a mapping table. Characters that are not in the table (e.g. Cyrillic or emoji) are dropped from the result.
Example:
var s = removeDiacritics('Česká republika'); // Returns “Ceska republika”
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 into the “RichTextBox” control at the current cursor position and marks the form as changed. The value is inserted as HTML – text entered by the user must therefore be encoded beforehand by the “htmlEncode” function.
Example:
rtb_Insert(#ng_richtextbox#, 'Inserted text');
void rtb_Resize(object rtb, int width)
The function sets the width of a RichTextBox and its fallback text area to “width” pixels. The “rtb” parameter is the RichTextBox text field used by client-side scripts.
Example:
rtb_Resize(#ng_description#, 700);
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);
});
Date Str2Date(string text [, Date defvalue])
The function parses a text string to a Date object. The order of day and month follows the date format set in NET Genium, not the separator used. It supports the time “HH:mm” and “HH:mm:ss”. Two-digit years are converted by adding 2000 (e.g. “25” returns 2025). If parsing fails, it returns “defvalue” or the current date and time.
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));
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” into the “TextArea” control specified by the “ta” parameter at the current cursor position and marks the form as changed. The function also supports a text field switched to the code editor.
Example:
ta_Insert(#ng_textarea#, 'Inserted text');
void ta_Resize(object ta, int width)
The function sets the width of the multiline text area “ta” to “width” pixels.
Example:
ta_Resize(#ng_note#, 700);
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));
}
void tb_LoadUrl(object e, string url, string mode [, int timeout])
After a keyboard event, the function loads suggestions from “url” with a delay and displays them next to the current text field. “timeout” specifies the delay in milliseconds and defaults to 250. Mode “p” also submits current form control values.
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 value [, string language])
The function returns the translated text from a multilingual string in the format “Default text#en:English#de:Deutsch”. Without the “language” parameter it returns the text in the language of the logged-in user – when rendering, NET Genium rewrites every “translate(” call in the JavaScript of controls to an internal call with the language of the user. The “language” parameter sets the language explicitly. If the string has no branch for the given language, it returns the default text before the first language marker. The language marker is the “#” character, a two-letter language code in lowercase and a colon; another “#” character in the text (for example “C# kurz#en:C# course”) does not split the text.
The rewrite applies only to JavaScript written in controls and events; it is not applied in a separate .js file, nor to a call preceded by a quotation mark or an apostrophe (for example “onclick="translate(...)"”). In both cases the function is called with the language as the first parameter: “translate(language, value)”.
Example:
var s = translate('Ahoj#en:Hello#de:Hallo'); // Returns the text in the language of the user
var s = translate('Ahoj#en:Hello#de:Hallo', 'de'); // Returns “Hallo”
var s = translate('Ahoj#en:Hello', 'fr'); // Returns “Ahoj”
string urlDecode(string value)
The function decodes a URL-encoded string – it converts %xx sequences (with uppercase or lowercase letters) back to characters in the UTF-8 encoding, so it is the counterpart of the “urlEncode” function. An invalid sequence (e.g. a lone “%” character in the text “discount 100%” or a sequence that is not valid UTF-8) remains unchanged and the function does not fail because of it; the “+” character is not converted to a space. An empty value (null) returns an empty string.
Example:
var s = urlDecode('%C4%8Desk%C3%A1'); // Returns “česká”
string urlEncode(string value)
The function encodes a string for use in a URL or in a request body. It uses the native encodeURIComponent function, so it encodes all characters except letters without diacritics, digits and the characters “- _ . ! ~ * ' ( )”, and characters outside ASCII as UTF-8. An empty value (null) returns an empty string, and damaged text (a lone half of a character in the UTF-16 encoding, typically a cut-off emoji) is encoded as the replacement character “�”.
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 at least 2 digits with a zero at the beginning. It is used for formatting time and date. A number that needs no padding is returned as a number, not as text; negative numbers are not padded.
Example:
var s = ZInt(5); // Returns “05”
var s = ZInt(12); // Returns 12
string ZInt4(int n)
The function pads a number to at least 4 digits with zeros at the beginning. It is used for formatting the year. A number that needs no padding is returned as a number, not as text; negative numbers are not padded.
Example:
var s = ZInt4(42); // Returns “0042”
var s = ZInt4(2024); // Returns 2024