473,509 Members | 2,863 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing variables in ASP.Net

BezerkRogue
68 New Member
This is the most fundamental action I am sure, but I can't seem to make it happen.

I am familiar with passing variables in ASP. But that doesn't seem to be the preferred method in .NET. I have some scripts that run at the server for the form so I can't disable that statement. I followed Microsoft's instructions(I know..not the best thing to do) but still can't get the variables to pass.

I created a class and set up an @reference statement, created property declarations to get the variables in the source page and set the server.transfer instruction to pass to the next page. The results....nothing. nada, zilch.

Can anyone help me out here?

Here's the inline script for the source page:
'Variable declaration for class object to encapsulate variables for page transfer
Dim fp As FirstPageClass

'Read property for Shift variable
Public ReadOnly Property Shift() As String
Get
Return SHIFT_ID.Text
End Get
End Property

'Read property for Date variable
Public ReadOnly Property SelDate() As String
Get
Return OccDate.SelectedDate
End Get
End Property

'Command string to pass the variables to next page
Sub cmdSubmit_OnClick(ByVal Sender As Object, ByVal e As EventArgs)
Server.Transfer("ChangeMPRep.aspx")

Here's the inline script for the receiving page:
Dim fp As FirstPageClass
Sub Page_Load()
Dim fp
If Not IsPostBack Then
fp = CType(Context.Handler, FirstPageClass)
End If
End Sub
Oct 22 '07 #1
6 2168
Plater
7,872 Recognized Expert Expert
You could use the Session object for this?
Oct 22 '07 #2
BezerkRogue
68 New Member
Is this the correct code to put in the VB file

Source page:

Session.Add("SelDate", OccDate.SelectedDate)
Session.Add("Shift", SHIFT_ID)

Receiving page: (Displaying variable in labels)

lblSelDate = Session("SelDate")
lblShift = Session("Shift")

I think that I might be missing something in between.
Oct 22 '07 #3
Plater
7,872 Recognized Expert Expert
That looks good, it's important to test for null though.
Expand|Select|Wrap|Line Numbers
  1. if (Session("SelDate") !=null)
  2. {
  3.    lblSelDate = Session("SelDate")
  4. }
  5. if (Session("Shift") !=null)
  6. {
  7.    lblShift = Session("Shift")
  8. }
  9.  
Oct 22 '07 #4
BezerkRogue
68 New Member
Got it. Would using context work as well? I am limited on server resources and this is shaping up to be a very busy site.

context.items.add("name", value)
Oct 22 '07 #5
Plater
7,872 Recognized Expert Expert
I am unfamiliar with "context" objects. Sorry.
Oct 22 '07 #6
nateraaaa
663 Recognized Expert Contributor
Got it. Would using context work as well? I am limited on server resources and this is shaping up to be a very busy site.

context.items.add("name", value)
You could also pass the variable as a querystring value.
page.aspx?id=variablevalue

Nathan
Oct 22 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2187
by: lawrence | last post by:
Those of you with backgrounds with the C language will laugh at my mistake, but those of you, like myself, who deal mostly with PHP should be warned about passing variables as references -...
7
10690
by: Matthew Robinson | last post by:
i read a tutorial the other day on passing variables between php pages using a html form and setting the action to the php page to parse, can anybody see anything wrong with the code below? the...
2
1908
by: Chieko Kuroda | last post by:
Hello all, I would like to learn the syntax for passing variables that I retreived from a database to a second asp page. Currently, I'm using: Response.Write "<tr><td>&nbsp;</td><td><Font size=...
1
3597
by: Consuelo Guenther | last post by:
Hello, I am having problems with passing variables between pages. I have the following: First asp page has the function: -----------------------------------------------------------------------...
7
2771
by: Khai | last post by:
First off, yes, I understand the crapload of tutorials out there, (well, rather, I understand there /are/ a crapload of tutorials out there), the problem is my comprehension. I'm trying to pass...
3
2104
by: jsdeveloper | last post by:
Hi, I just started programming in javascript, and I'm having a problem passing variables between javascript and asp code in .asp page. Can you please help? I've given the sample code below. ...
1
2201
satterfieldben
by: satterfieldben | last post by:
I have a newbie question about passing variables between functions. I am wanting to use a drop down box to select a value. Then base on which was selected, it would create a variable and I would call...
5
1516
by: Shawn Northrop | last post by:
test.php: <?php $d=$_GET; echo $d; ?> when i go to www....com/test.php?data=1 nothing happens.
6
3284
by: coool | last post by:
Hi :) anyone knows how can I send variables from a php page to a form - i need to fill the form with these variables ? maybe using (the process of passing variables to other pages - through...
1
7073
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...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5656
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5062
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
3218
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
3207
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1571
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
779
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
443
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.