joe_pool_is Posted August 4, 2004 Posted August 4, 2004 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 Quote Avoid Sears Home Improvement
Moderators Robby Posted August 4, 2004 Moderators Posted August 4, 2004 I have spelled out a few options here http://www.bassicsoftware.com/popup.aspx?b_id=156 Quote Visit...Bassic Software
TwistedNerve Posted August 4, 2004 Posted August 4, 2004 You can take advantage of the Context.Items collection to pass/persist information for the duration of the current request. Quote
*Gurus* Derek Stone Posted August 4, 2004 *Gurus* Posted August 4, 2004 TwistedNerve: That will only work on the currently executing page. It will not work between pages, when the Context.Items collection will be flushed, unless Server.Transfer() is being invoked, which is a problem that needs fixing in and of itself. Quote Posting Guidelines
TwistedNerve Posted August 4, 2004 Posted August 4, 2004 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. Quote
joe_pool_is Posted August 4, 2004 Author Posted August 4, 2004 TwistedNerve and Derek Stone: I have always used Server.Transfer() to load the next page. Is there another (or better) way? I would be interested to learn how and when to use one method over another. Quote Avoid Sears Home Improvement
Arch4ngel Posted August 4, 2004 Posted August 4, 2004 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 ! :) Quote "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* Derek Stone Posted August 4, 2004 *Gurus* Posted August 4, 2004 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. Quote Posting Guidelines
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.