Retrieve session var from .net page and use in VBScript

F

Frank

Can I do this?

I add a session var in C# and ultimatly want to pass it into a vbscript
client side activeX control. This is what I have so far but get " Object
Required:'name2' " error.

Can anyone suggest a btter way of passing a session var into a vbscript
function?

<%@ Page language="c#" debug="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<script runat="server">
void Page_Load()
{
if(Page.IsPostBack)
{

}
else
{
//get name from TextBox
string myVar =name.Value;

//add name to session
Session.Add("sessionVar1", myVar);

//store session var in a hidden input so it can be retrieved from
VBScript
string retrievedSessionVar=(string) Session["sessionVar1"];

//show that var was retrieved successfully
HiddenInput1.Value = retrievedSessionVar;
}
}
</script>

<script language="vbscript">

private sub fill(HiddenInput1)
dim Name
Name = HiddenInput1.value
retrieve(Name)
end sub

private sub retrieve(Name)
name2.value=Name
end sub

</script>


<html>
<head>
<title>Test</title>

</head>
<body>
<form>
<p>
<input type="text" ID="name" Value="Frank" runat="server">
simply stores and shows the session var value </p>
<p><br>
<input type="text" ID="name2" name="name2">
This is the box that should display the session var via the vbscript
</p>
<p><br>
<input type="button" value="Fill" onclick="fill(HiddenInput1)"
runat="server">
<br>
<br>
<input type="text" id="HiddenInput1" runat="server">
This will be the hidden labe...it just shows that the session var was
retrieved </p>
</form>
</body>
</html>
 
G

Guest

<%@ Page language="c#" debug="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<script runat="server">
void Page_Load()
{
if(Page.IsPostBack)
{

}
else
{
//get name from TextBox
string myVar =name.Value;

//add name to session
Session.Add("sessionVar1", myVar);

//store session var in a hidden input so it can be retrieved from
//VBScript
string retrievedSessionVar=(string) Session["sessionVar1"];

//show that var was retrieved successfully
HiddenInput1.Value = retrievedSessionVar;
}
}
</script>

<script language="vbscript">

private sub fill()
dim Name
Name = document.all.HiddenInput1.value
retrieve(Name)
end sub

private sub retrieve(Name)
document.all.name2.value=Name
end sub

</script>


<html>
<head>
<title>Test</title>

</head>
<body>
<form>
<p>
<input type="text" ID="name" Value="Frank" runat="server">
simply stores and shows the session var value </p>
<p><br>
<input type="text" ID="name2" name="name2">
This is the box that should display the session var via the vbscript
</p>
<p><br>
<input type="button" value="Fill" onclick="fill()"
runat="server">
<br>
<br>
<input type="text" id="HiddenInput1" runat="server">
This will be the hidden labe...it just shows that the session var was
retrieved </p>
</form>
</body>
</html>

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




Frank said:
Can I do this?

I add a session var in C# and ultimatly want to pass it into a vbscript
client side activeX control. This is what I have so far but get " Object
Required:'name2' " error.

Can anyone suggest a btter way of passing a session var into a vbscript
function?

<%@ Page language="c#" debug="true" ContentType="text/html"
ResponseEncoding="iso-8859-1" %>
<script runat="server">
void Page_Load()
{
if(Page.IsPostBack)
{

}
else
{
//get name from TextBox
string myVar =name.Value;

//add name to session
Session.Add("sessionVar1", myVar);

//store session var in a hidden input so it can be retrieved from
VBScript
string retrievedSessionVar=(string) Session["sessionVar1"];

//show that var was retrieved successfully
HiddenInput1.Value = retrievedSessionVar;
}
}
</script>

<script language="vbscript">

private sub fill(HiddenInput1)
dim Name
Name = HiddenInput1.value
retrieve(Name)
end sub

private sub retrieve(Name)
name2.value=Name
end sub

</script>


<html>
<head>
<title>Test</title>

</head>
<body>
<form>
<p>
<input type="text" ID="name" Value="Frank" runat="server">
simply stores and shows the session var value </p>
<p><br>
<input type="text" ID="name2" name="name2">
This is the box that should display the session var via the vbscript
</p>
<p><br>
<input type="button" value="Fill" onclick="fill(HiddenInput1)"
runat="server">
<br>
<br>
<input type="text" id="HiddenInput1" runat="server">
This will be the hidden labe...it just shows that the session var was
retrieved </p>
</form>
</body>
</html>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top