|
Sometimes you need to access ASP variables, such as name of
logged user or group to which he belongs, in Javascript. To do this
you need to complete the following steps:
1. Proceed to the Visual
Editor page and select a page where required variables is
initialized (e.g. Login page). Create ASP code snippet and add the
following code there:
|
Response.write "<script>" & _
"window.username = '" & Session("UserID") & "';" & _
"window.group = '" & Session("GroupID") & "';" & _
"</script>"
|
2. Use new variables (username and group) in Javascript OnLoad event. For example, make a
control disabled, if user in not admin:
|
if (username!='admin')
{
var ctrl = Runner.getControl(pageid,
'Comments');
ctrl.setDisabled();
}
|
See also
|