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
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
Has a.aspx already been loaded? Or are you looking to just incorperate a.aspx into b.aspx?
 

garcon

Well-known member
Joined
Dec 13, 2004
Messages
47
Programming Experience
Beginner
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.
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
Use a session variable, in a.aspx session("whatever")=your variable in b.aspx something = session("whatever")
 

Schenz

Well-known member
Joined
Sep 11, 2004
Messages
181
Location
Cincinnati, OH
Programming Experience
5-10
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")
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
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.
 

Schenz

Well-known member
Joined
Sep 11, 2004
Messages
181
Location
Cincinnati, OH
Programming Experience
5-10
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.
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
Indeed. The only problem with cookies is they can be disabled.
 

Schenz

Well-known member
Joined
Sep 11, 2004
Messages
181
Location
Cincinnati, OH
Programming Experience
5-10
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.
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
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.
 

Schenz

Well-known member
Joined
Sep 11, 2004
Messages
181
Location
Cincinnati, OH
Programming Experience
5-10
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?
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
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)
 

Schenz

Well-known member
Joined
Sep 11, 2004
Messages
181
Location
Cincinnati, OH
Programming Experience
5-10
Ok, that makes sense to me, and I forgot that .NET Sessions were avaialbe to all the servers in the cluster.....
 

TPM

Well-known member
Joined
Dec 7, 2004
Messages
623
Location
CA
Programming Experience
3-5
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.
 

tiffany

Well-known member
Joined
Aug 7, 2005
Messages
57
Programming Experience
1-3
From Schenz's Post:

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:

Code:
Dim ParamString As String ParamString = "LastName=" & txtLastName.Text ParamString += "&FirstName=" & txtFirstName.Text Response.Redirect("CustomerList.aspx?lookup=name&" & ParamString)​



Using a request variable:


Code:
txtLastName.Text = Request.Params.Item("LastName") txtFirstName.Text = Request.Params.Item("FirstName")​



Hi Schenz, regarding from the reply post. I would like to ask you for help. For the "setting request variable", i had try the codes for checkboxes and do the same for "using a request variable". But how to retrieve more then one values in checkboxes and display in another page? Thank you!
 
Top Bottom