473,839 Members | 1,358 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing variables in ASP.Net

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....noth ing. 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
Return SHIFT_ID.Text
End Get
End Property

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

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

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.H andler, FirstPageClass)
End If
End Sub
Oct 22 '07 #1
6 2200
7,872 Recognized Expert Expert
You could use the Session object for this?
Oct 22 '07 #2
68 New Member
Is this the correct code to put in the VB file

Source page:

Session.Add("Se lDate", OccDate.Selecte dDate)
Session.Add("Sh ift", SHIFT_ID)

Receiving page: (Displaying variable in labels)

lblSelDate = Session("SelDat e")
lblShift = Session("Shift" )

I think that I might be missing something in between.
Oct 22 '07 #3
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. }
Oct 22 '07 #4
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.a dd("name", value)
Oct 22 '07 #5
7,872 Recognized Expert Expert
I am unfamiliar with "context" objects. Sorry.
Oct 22 '07 #6
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.a dd("name", value)
You could also pass the variable as a querystring value.
page.aspx?id=va riablevalue

Oct 22 '07 #7

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

Similar topics

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 - debugging then requires a whole new mindset. I've a cms written in procedural style that I've been converting to OOP. It is important to always pass objects by reference. Unthinkingly, writing the constructors, I also passed my config array by reference....
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 problem is, that the page always loads the html form, and i cant work out why this is so, even after i select a catagory from the drop down list and press search. any1 have any idea's? TIA. the code: if (empty($catagory)) { ?>
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""><B><a href= ""InterviewerInfo2.asp?timeID=" & rs("Starttime") & " "">" How do I add more variables to my link: <a href = ...? ie Nameofcandidate and InterviewDate in this context:
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: ----------------------------------------------------------------------- <script language="JavaScript"> function addProcess(addPName,addSProcess,addPIndex) { var addProcessWindow = window.open('second.asp','mywindow','width=400,height=200');
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 variables, and can do so just fine with a URL, and $_GET. What I would like to learn, and be very adept at using is the Form functions and how you pass through that. The problem in my comprehending this, is how does the original page know how...
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. ---------------------------------------------------------------------------------- <script src="http://www.aurumtech.com/domain_str.js" type="text/javascript"></script> <script type="text/javascript"> var email_str = "joe@example.com" var...
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 that variable in another Java script. Sample script <SCRIPT LANGUAGE="JavaScript"> function GetSelectedItem() { len = document.formname.selectname.length i = 0 chosen = "none"
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.
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 url) but how can i assign them to form variables ?
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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 we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.