Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics > Page class > Methods

setProxyValue

Scroll Prev Next More

 

Sets the variable to the given value. Use the setProxyValue() method to pass C#/VB.NET values to JavaScript: you assign value to a variable in C#/VB.NET and then use it in JavaScript.

 

This method is available on all pages and needs to be added to BeforeDisplay event.

Syntax

 

setProxyValue(name, value)

Arguments

name

any variable name. Example: "master".

value

the value assigned to the variable. value may be a simple value (e.g., string, number) or an array.

Return value

No return value.

Example 1

Setting and using regular variables and arrays. This code goes to BeforeDisplay event.

 

pageObject.setProxyValue("name", "some value");
pageObject.setProxyValue("master",pageObject.getMasterRecord());

 

Use the name and master variables in JavaScript OnLoad event:

 

alert(proxy['name']);
alert(proxy.master['Make']);

Example 2

Using C#/VB.NET values in button's Javascript code.

 

BeforeDisplay event:
 

 

pageObject.setProxyValue("name", "some value");

 

 

 

Javascript OnLoad event:

 

window.proxy = proxy;

 

Button's ClientBefore or ClientAfter event

 

alert(window.proxy['name']);

See also:

RunnerPage class: getMasterRecord()

Event: AfterAdd

Event: AfterEdit

Event: JavaScript OnLoad

Example: How to display any page in a popup window

About RunnerPage class