By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,537 Members | 1,471 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,537 IT Pros & Developers. It's quick & easy.

Retrieve session var from .net page and use in VBScript

P: n/a
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>
Dec 5 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
<%@ 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" wrote:
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>

Dec 5 '05 #2

P: n/a
Peter,

Thank you soooo very much. That is a great help.

I had not seen any examples where 'document.all' was used.

That is why I had tried to pass the control as a parameter.

Thank you for your time,

Frank

*** Sent via Developersdex http://www.developersdex.com ***
Dec 5 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.