473,498 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Retrieve session var from .net page and use in VBScript

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
2 2837
<%@ 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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1706
by: Chung Leong | last post by:
My contribution to the comp.lang.php FAQ: ------------------------------------------------------------- Q: How do I retrieve a page from a web site? A: Pass a URL to file() or...
5
11178
by: David Rasmussen | last post by:
Some sites seem to be session driven in the sense that if I visit the homepage and do a few clicks I can navigate anywhere I want, but if I paste the current location into a new browser window...
9
3688
by: Colin Graham | last post by:
hi folks, just wonder if this is possible or is there a better way of doing this. i need to store values in cookies between two forms. the details are added in a popup when this is closed the...
1
2687
by: niftyhawk | last post by:
Hi, How do I store and retrieve session state information using C# and ASPState SQL Server Database? Thanks
5
1577
by: tuxedo | last post by:
Hi, Gurus, I have two web forms frm1 and frm2. In frm1, I wrote session("StudentID")= textbox1.text in a button click event. And then, Response.redirect("...frm2") In frm2, Page_load event, I...
1
1451
by: Frank | last post by:
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...
1
1707
by: irfangani | last post by:
Hi, I have two web applications one in VB.Net and other in C#. I am using Out-Process session state using SQL server. I create a session in VB.Net application. If I access the session in the...
2
1251
by: pieterprovoost | last post by:
Hi, I'm having problems retrieving the contents of an external web page. When I open this page on my computer, I get some results: ...
0
1392
drhowarddrfine
by: drhowarddrfine | last post by:
Background: I have someone who uses Windows XP and software he bought for a cash register. He also has an online order form. When someone orders something online, we'd like for the XP box to...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7004
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7167
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6890
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4915
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3095
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1423
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
657
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
292
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.