Server Side vs Client Side variables on ASP pages

H

Thread Starter

Hellstern, Manny

I am developing an ASP application with ActiveX controls and some COM objects for our client's intranet. We automatically retrieve field data from flow computers and store the data in an Oracle database, and then automatically download analysis to the flow computers when it is available. The EFM's are tied together using
Intellution FixDynamics SCADA system. The ASP application will allow users to select the database they want to connect to, and generate reports.

The problem I am having is getting information to flow between the Server and Client sides of the application. The specific questions I have are as follows

1. How do I access a "session" variable from the client side?
2. How do I get access to a server side variable from the client side?

An example would be, I have an ActiveX listbox control that is populated via a server side script. I want to use the value of the item selected by the user in a client side function.


Regards,

Manny J. Hellstern
Sr. Consulting Engineer
Mustang Engineering
(713) 215-8380
[email protected]
 
W

Walters Curt L Contr AEDC/SVT

Manny,

Although I am new to the ASP world, I have tried to solve your problem. If I understand your problem correctly, I think that you basically want to use the values of session variables in a client-side script. I, too, have been unable to access the session variables or any of the server-side stuff from client side scripts.

However, a possible workaround is to use an HTML form list box (or any other HTML form item) instead of the ActiveX list box. The values of the session variables goes right into the HTML form list boxes. Just substitute:

<% session("session_variable_name") %>

where you would normally have text strings.

Be careful, though, this sounds like "high tech" stuff- ha, ha. (referring to some of the other e-mails coming from this chat list).

I hope it helps. Please let us know your outcome.

Curt Walters, PE
 
C

Christopher Griffin

I havent been following this thread at al, and I'm not a VBScript person. But you can pass parameters to the client side by putting them into hidden fields in forms

<FORM name="server_side_stuff">
<INPUT type="hidden" name="server_parameter_1"
value="value_1">
</FORM>

Accessing them is easy in JavaScript where you call

form.server_side_stuff.server_parameter_1

or other stuff nonsense.
 
A

Andrew Piereder

I have some (successful) experience with this, although not specifically with process variables. Some of this may be redundant to you. I use VBScript...

1. Set your pointer variable to Server.CreatObject("ADODB.Recordset")
2. Define your SQL statement (I usually set a string variable equal to the
statement for convenience...)
3. Use the Open property to trigger the SQL and ID your DSN -- oRS.Open
sqltext, "DSN=Oracle"

From here you can use other properties like MoveFirst, MoveNext, etc... to read records into the current buffer and manipulate them by Response.Write statements into tables or list boxes.

You can pass data from the table to a client-side function by response.writing a form and having the submit form method trigger a parameter pass of the explicit and hidden variables you choose to a page (action). Within the form method, the variables are named and set equal to a db record in the current buffer (flow = oRS("flow")). The variables and their values are passed in the URL.

The variables are accessed by the function page by using the Request.Querystring object and property (Request.Querystring("flow")) by
setting it equal to a local variable or using it as is within the activeX parameters.

Andy Piereder
Pinnacle IDC
 
R

Robert Jones Jr

Using VBScript it is quite simple to grab Server Side Variables within Client Side Script, However I have yet been unable to figure out the reverse. Sample Code... &lt;SCRIPT LANGUAGE=vbscript> ClientVar1 = "<%=Session("ServerVar1")%>" Msgbox ("Variable Is: " & ClientVar1) &lt;/SCRIPT>
 
C
The example you provided is not correct. You are grabbing a client variable...not a server variable. -cb [email protected] > Using VBScript it is quite simple to grab Server Side Variables within Client Side Script, However I have yet been unable to figure out the reverse. > > Sample Code... > > &lt;SCRIPT LANGUAGE=vbscript> > ClientVar1 = "<%=Session("ServerVar1")%>" > Msgbox ("Variable Is: " & ClientVar1) > &lt;/SCRIPT> >
 
I haven't found a way to import the variable into client-side VBScript yet, so I basically had to learn some JavaScript. Here's an example. &lt;script language="JavaScript1.2"&gt; var clientVariable = &lt;%=serverVariable%&gt;; function main() { //your code goes here } &lt;/script&gt;
 
Top