Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

From a form, how can I carry the data from one Form (say a Customer's Name) to another Form?

 

Example:

From Form1: (assume txtName.Text = "Herman Munster")

Private Sub cmdSubmit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click
Server.Transfer("Form2.aspx")
End Sub

From Form2:

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
lblName.Text = "" 
' Can't assign to Form1.txtName.Text.
' So how would I do this?
End Sub

Posted
Derek Stone: Yes, I am aware that it only works when invoking Server.Transfer (I stated, "duration of the current request"), and the reason I mentioned Context.Items collection is because his code example is using the Server.Transfer method. Also, just out of curiosity, what type of problems have you run into with the transfer method? I personally dont use it, but would like to hear your thoughts.
Posted

Personally... I use QueryString (from Request and Response object - depend on what you are trying to do, read or write) if the data isn't DataBase linked and or it doesn't matter if the user modify it (like email, name, first name, etc....)

 

If the Data is sensible or that is linked to a DB and it would REALLY be a problem if the user modify something (validated data) then I use the Session object (that is unique to each user).

 

Want more info ? Ask on this thread ! :)

"If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown

"Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me

"A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend.

C# TO VB TRANSLATOR

  • *Gurus*
Posted

joe_pool_is: In all but a very few situations, such as wizards and authentication/authorization redirects, you should instead be using Response.Redirect().

 

Server.Transfer() has its place, but it is very defined and limited. It should be used when the current request is part of a series of requests (such as a "new user" wizard), where the user shouldn't be navigating to any portion of the wizard directly (it's an all or nothing process, either complete the wizard at that time or don't at all). It should also be used when the user is being denied access to a resource (HTTP response code 401/403), at which time the client shouldn't be given a chance to redirect (HTTP response code 301/303).

 

For all other situations Response.Redirect() is more appropriate. It clearly notifies both the browser and the user of the change in pages. The URL will be updated on the client, the browser's history will reflect the user's location accurately, and most importantly the page will be executing in the intended context.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...