Re: asp question about post vars
From: Kevin Spencer (kevin_at_DIESPAMMERSDIEtakempis.com)
Date: 02/22/05
- Next message: donnet: "Re: how to edit a textbox field populated by data from a datalist?"
- Previous message: Bernie Yung: "Disabling ASPX page"
- In reply to: glenn: "asp question about post vars"
- Next in thread: glenn: "Re: asp question about post vars"
- Reply: glenn: "Re: asp question about post vars"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 22 Feb 2005 14:30:14 -0500
> I've had a couple people tell me that I need to do query strings and pass
> all the values on the form over individually but surely there is a better
> solution. Can anyone tell me the best way to take a form with a lastname
> and firstname field and pass them through a post to a result page and then
> access those fields values on the result page?
This is kind of like that old joke: How do I get to Broadway? (Answer:
practice). Although the punch line is a joke, the question is similar. There
are many ways to "get to Broadway." Taking a cab might not be the best way
if you're riding in a bus. Taking the subway is fast, as long as you're near
a subway station.
So, the first issue you will want to know is, what are the various ways that
data can be passed from one page in an ASP.Net app to another?
1. QueryString. This is useful when you're hyperlinking from one page to the
other, and no security requirement dictates that the data should not appear
to the user.
2. "Traditional" form post. Yes, with ASP.Net you can still post a form to
another page, but not a WebForm. This is an unusual case, so I won't bother
with it.
3. PostBack and Server.Transfer. Post the form back to itself. On the
server-side, do a Server.Tranfer to transfer the context to a new page. This
is useful when you don't want the user to know what data you're passing.
4. PostBack and Response.Redirect. Post the form back to itself. On the
server side, do a Response.Redirect. This sends a header to the browser
telling it to request the second URL. This method has the same drawbacks as
number 1.
5. PostBack, store data in Session (or Application, depending upon the scope
you want), and Redirect or Transfer. This is like numbers 3 and 4, but it
uses Session space on the server to store the data. This way, no QueryString
is needed, but you have to be careful about Session Timeouts.
That's about all I can think of at the moment. Choose the method that works
best in a given situation.
-- HTH, Kevin Spencer Microsoft MVP .Net Developer Neither a follower nor a lender be. "glenn" <ghan***@softeksoftware.com> wrote in message news:%23kxXuIRGFHA.2928@TK2MSFTNGP14.phx.gbl... >I am use to programming in php and the way session and post vars are past > from fields on one page through to the post page automatically where I can > get to their values easily to write to a database or continue to process > on > to the next page. > > I am now trying to learn ASP to see if we can replace some of our > applications that were written in php with an ASP alternative. However, > after doing many searches on google and reading a couple ASP books to try > to > figure out this simple task I'm still without a solution. > > I've had a couple people tell me that I need to do query strings and pass > all the values on the form over individually but surely there is a better > solution. Can anyone tell me the best way to take a form with a lastname > and firstname field and pass them through a post to a result page and then > access those fields values on the result page? > > Thanks, > > glenn > >
- Next message: donnet: "Re: how to edit a textbox field populated by data from a datalist?"
- Previous message: Bernie Yung: "Disabling ASPX page"
- In reply to: glenn: "asp question about post vars"
- Next in thread: glenn: "Re: asp question about post vars"
- Reply: glenn: "Re: asp question about post vars"
- Messages sorted by: [ date ] [ thread ]