Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Passing Form Data

Reply
Thread Tools

Passing Form Data

 
 
Mike
Guest
Posts: n/a
 
      12-03-2004
I'm moving to ASP.NET and was wondering what is the best way to pass
form data from one aspx page to another?

Mike
 
Reply With Quote
 
 
 
 
Peter Rilling
Guest
Posts: n/a
 
      12-03-2004
Like all things computer science related, "best" is a relative term and
depends on your needs.

Here are your options:
1) Querystring
2) Session variables
3) Application variables
4) Static variables.
5) Cookies
6) (and probably others)

I, myself, try to stay away from things that persist on the server like
static variables because they can sometimes be difficult to troubleshoot a
site since they can be set by any pieces of code. I usually like
querystrings because they can get set by the user manually which might help
in debugging as you can jump to a scinerio immeidatly. But this all depends
on your needs.

"Mike" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> I'm moving to ASP.NET and was wondering what is the best way to pass
> form data from one aspx page to another?
>
> Mike



 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      12-03-2004
What's the best way to get from Chicago to New York? Answer: It all depends
on requirements and circumstances.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Mike" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> I'm moving to ASP.NET and was wondering what is the best way to pass
> form data from one aspx page to another?
>
> Mike



 
Reply With Quote
 
Scott M.
Guest
Posts: n/a
 
      12-03-2004
What you may not be aware of is that in .NET, we use a one-page form
paradigm. That is that in .NET, form data is submitted to the same page.
So, the need to move form data from one page to another is no really needed.

The first time a page loads (before the user has had a chance to submit
anything) is referred to as "not a postback". A page that is loading for
the 2nd or 200th time because form data was submitted is called a
"postback". When a page is loading up, you'll want to know if the page is
loading because form data was submitted (and therefore, you want to access
that data and use it) or is the page loading for the first time (or because
of a refresh). We can use this code (VB.NET) to check:

Sub Page_Load
If Not IsPostBack Then
'Page is loading for either the first time or as the result of a
refresh

Else
'Page is loading as a result of the form data being submitted
'Access the form data directly via the control names you used to
create the form

End If
End Sub

Of course, if you need to use that form data on subsequent pages, you can
still use classic ASP mechanisms to do it (QueryStrings, Hidden Form Fields,
Server.Transfer, etc.) and you can use new .NET mechanisms as well (adding
data to the cache, global shared variables, custom objects, etc.).


"Mike" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> I'm moving to ASP.NET and was wondering what is the best way to pass form
> data from one aspx page to another?
>
> Mike



 
Reply With Quote
 
Amstaff
Guest
Posts: n/a
 
      12-03-2004
Personally I prefer the ValueHolder designe pattern.
Create a class that has properties for all the form values
you need to keep. In the code behind of the submitting
aspx create the the valueholder set all the values and the
pass it along either on the request or into a service
layer.
>-----Original Message-----
>Like all things computer science related, "best" is a

relative term and
>depends on your needs.
>
>Here are your options:
> 1) Querystring
> 2) Session variables
> 3) Application variables
> 4) Static variables.
> 5) Cookies
> 6) (and probably others)
>
>I, myself, try to stay away from things that persist on

the server like
>static variables because they can sometimes be difficult

to troubleshoot a
>site since they can be set by any pieces of code. I

usually like
>querystrings because they can get set by the user

manually which might help
>in debugging as you can jump to a scinerio immeidatly.

But this all depends
>on your needs.
>
>"Mike" <(E-Mail Removed)> wrote in

message
>news:#(E-Mail Removed)...
>> I'm moving to ASP.NET and was wondering what is the

best way to pass
>> form data from one aspx page to another?
>>
>> Mike

>
>
>.
>

 
Reply With Quote
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      12-03-2004
Here's a nice, simple way to pass values from one page to another:
(VB.NET code)

'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")

Then, in WebForm2.aspx:

'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)

Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
http://msdn.microsoft.com/msdnmag/is...e/default.aspx

http://www.aspalliance.com/kenc/passval.aspx

http://www.dotnetjunkies.com/tutoria...tutorialid=600

http://www.dotnetbips.com/displayarticle.aspx?id=79

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


"Mike" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> I'm moving to ASP.NET and was wondering what is the best way to pass form
> data from one aspx page to another?
>
> Mike



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Read data from enctype="multipart/form-data" form Kevin DeValck Ruby 1 05-17-2011 06:14 PM
passing values from one web form to another web form bbawa1@yahoo.com ASP .Net 5 06-12-2007 05:50 AM
How passing values from a form through another form DanC ASP General 2 01-24-2005 07:53 AM
passing arguments from web-form to win-form Mart Rogers ASP .Net 3 07-09-2003 07:18 AM
passing arguments from web-form to win-form Mart Rogers ASP .Net Web Services 2 07-08-2003 04:23 PM



Advertisments