472,983 Members | 2,275 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,983 software developers and data experts.

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 2811
<%@ 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
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
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
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
by: niftyhawk | last post by:
Hi, How do I store and retrieve session state information using C# and ASPState SQL Server Database? Thanks
5
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
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
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
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
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...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.