Webform to webform transfer when loading

garcon

Well-known member
Joined
Dec 13, 2004
Messages
47
Programming Experience
Beginner
Folks,


Is it possible for one webform to automatically request some variables from another webform with it loads up.
For example let say that when "b.aspx.vb" loads up it get some variables from "a.aspx.vb"
Is this possible and how do you do it?

thanks,
g
 
Has a.aspx already been loaded? Or are you looking to just incorperate a.aspx into b.aspx?
 
Yes - "a.aspx.vb" has already been loaded. When the user clicks on an image "b.aspx.vb" gets laoded. I want "b.aspx.vb" to pull infor from "a.aspx.vb".

I've been trying stuff likwe:

Dim a As a
a.aspx.vb = Ctype(context.Handler, a.aspx.vb)
Dim variable1 As String = a.property1

But it says: type expected under the second "a". Any ideas??

G.
 
Use a session variable, in a.aspx session("whatever")=your variable in b.aspx something = session("whatever")
 
I would strongly recommend you avoid using session variables. They are easy, and work wonders, but they can get out of hand and use server resources.

Look into Request variables.

Setting a request variable:
VB.NET:
 Dim ParamString As String
 ParamString = "LastName=" & txtLastName.Text
 ParamString += "&FirstName=" & txtFirstName.Text
 
 Response.Redirect("CustomerList.aspx?lookup=name&" & ParamString)

Using a request variable:
VB.NET:
 txtLastName.Text = Request.Params.Item("LastName")
 txtFirstName.Text = Request.Params.Item("FirstName")
 
It depends what the variable is... I wouldn't want to try and pass a dataset as a request variable for example.

Request variables are also not visually secure - if I login to a site I don't want my username and password displayed at the top of my screen for anyone near by to read.
 
Agreed.

The best solution tends to be a combination of session varaibles (Keeping them small and make sure you clean up after yourself), request variables, and cookies.

I like to use cookies for items such as a user logging in (and remembering user settings), and they are just as easy to use as session variables and request variables.
 
Yes, cookies may be turned off, but most people surfing the internet do not know what they are much less how to turn them off.

If they are bright enough to turn them off then they know the consequences.

That is why most sites (including this one) use cookies to be able to log you in when you first come back. Track what posts are new, etc...

No I would not advocate using cookies to pass say a price of an item from one page to a cart page. That would not be wise, but to use a cookie to log someone into the site from day to day I believe is acceptable.
 
Right, I'm just saying you wouldn't want to force the use of cookies. Ie if my cookies are turned off I can still log into this sight.
 
Very True.

So to recap:

Session Variables: Recommended to be small in size. Take Server resources

Request Variables: Recommended to be small in size. Visible in address bar of browser

Cookies: Recommended to be small in size. User may have cookies turned off.

How would you pass something larger such as a dataset? Make the DataSet availalbe application wide?
 
I'd still use a session variable, if size is a possible issue you can lower the session time out (default 20 mins) or use session.abandon().

Although I doubt you dataset size is going to be a problem (a bataset is only going to be a few K), or at least not the first problem. If you have that many visitors to you site that the number of datasets in memory is causing a problem, the traffic is going to kill the server anyway...

Also unlike regular asp sessions, .net sessions can be accessed through out a server cluster.

The other thing to consider is what's the alternative? If you stored the information in a db or file you'd have twice the problem..

However thing like graphics etc that take a LOT of room obviously aren't a good idea to be adding to session variable (unless your user base is tiny perhaps)
 
Of course if you wanted to transfer Images and such you wouldn't transfer the image itself, but the code to load it, as it will also be rendered at runtime.
 
Back
Top