New to ASP.Net forms (and Session variables??)

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default New to ASP.Net forms (and Session variables??)

    I'm trying to write a simple "register form / validate and store in
    database / show welcome screen" application with ASP.Net. With
    conventional ASP, I used Session variables and it went something like
    this:

    *****
    form.asp

    - <form action="ValidateAndStore.asp" method="post">

    *****
    ValidateAndStore.asp

    - Pass form values into Session variables.

    - If validation OK Then
    Store in database
    redirect("welcome.asp")
    Else
    redirect("form.asp?error=ValidateError")
    End If

    *****
    welcome.asp

    - Show form values using previously stored Session variables


    I know there are no need for Session variables in ASP.Net forms
    because the state is preserved. All tutorials and books I've read so
    far show how to post ASP.Net forms to itself (post back), but how do I
    validate and redirect to *another* page without losing the form
    variables??? Do I have to use Session variables again even with
    ASP.Net forms??
    Jessica Loriena Guest

  2. Similar Questions and Discussions

    1. #39833 [NEW]: Session variables overwritten by local variables (register_globals=off)
      From: sup1382 at accedo dot es Operating system: OpenBSD 3.9 PHP version: 5.2.0 PHP Bug Type: Session related Bug...
    2. #39447 [NEW]: Want to optionally handle apc_upload_progress variables using session variables
      From: krudtaa at yahoo dot com Operating system: All PHP version: 5.2.0 PHP Bug Type: Feature/Change Request Bug...
    3. Session problem when setting session variables in files that are in different directories
      I am running PHP 4.3.0 on a WinXPpro machine and I recently got problem with sessions. What I am building is a loginsystem and I need to save...
    4. variables that change session variables
      Hi, I'm currently writing a mulit-page form app that uses a session to retain data from each form element in order for the user to jump between...
    5. forms and variables.
      I would recommend session variables. Try this: http://www.macromedia.com/support/ultradev/ts/documents/passingformdata.htm -- Mike ...
  3. #2

    Default Re: New to ASP.Net forms (and Session variables??)

    you are free to Response.Redirect all you want in asp.net...i think the
    difference is that instead of accessing/parsing the form post variables
    directly, you will get the data from the controls that contain the data,
    much like a windows form. State is preserved on the controls for that page
    via the ViewState....if you need specific data outside of the current form,
    then you are free to use Session state, the asp.net Cache object, or query
    your db for specific data in the form.

    IMO, asp.net does not discourage the use of Session...in fact, i believe
    it's a great way to store data in objects as opposed to the only real option
    of primitive types in classic asp.


    "Jessica Loriena" <jloriena@hotpop.com> wrote in message
    news:9beb2b43.0307292113.3defdc8e@posting.google.c om...
    > I'm trying to write a simple "register form / validate and store in
    > database / show welcome screen" application with ASP.Net. With
    > conventional ASP, I used Session variables and it went something like
    > this:
    >
    > *****
    > form.asp
    >
    > - <form action="ValidateAndStore.asp" method="post">
    >
    > *****
    > ValidateAndStore.asp
    >
    > - Pass form values into Session variables.
    >
    > - If validation OK Then
    > Store in database
    > redirect("welcome.asp")
    > Else
    > redirect("form.asp?error=ValidateError")
    > End If
    >
    > *****
    > welcome.asp
    >
    > - Show form values using previously stored Session variables
    >
    >
    > I know there are no need for Session variables in ASP.Net forms
    > because the state is preserved. All tutorials and books I've read so
    > far show how to post ASP.Net forms to itself (post back), but how do I
    > validate and redirect to *another* page without losing the form
    > variables??? Do I have to use Session variables again even with
    > ASP.Net forms??

    PJ Guest

  4. #3

    Default Re: New to ASP.Net forms (and Session variables??)

    Using the Session is certainly appropriate in many cases. ASP.Net provides a
    larger number of caching options. It's just a matter of determining the most
    appropriate caching mechanism to use according to the requirements of the
    part of the app which you are building. Sessions provide a method of storing
    data in memory across multiple pages for a single client, for the duration
    of that client Session. This functionality is not provided by other caching
    mechanisms. If that is the functionality needed, by all means, use it.

    It is important to familiarize yourself with the various caching mechanisms
    available, in order to make the best choice in any given situation.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    [url]http://www.takempis.com[/url]
    Complex things are made up of
    lots of simple things.

    "PJ" <pjwalNOSPAM@hotmail.com> wrote in message
    news:%23rZ2WvnVDHA.2340@TK2MSFTNGP10.phx.gbl...
    > you are free to Response.Redirect all you want in asp.net...i think the
    > difference is that instead of accessing/parsing the form post variables
    > directly, you will get the data from the controls that contain the data,
    > much like a windows form. State is preserved on the controls for that
    page
    > via the ViewState....if you need specific data outside of the current
    form,
    > then you are free to use Session state, the asp.net Cache object, or query
    > your db for specific data in the form.
    >
    > IMO, asp.net does not discourage the use of Session...in fact, i believe
    > it's a great way to store data in objects as opposed to the only real
    option
    > of primitive types in classic asp.
    >
    >
    > "Jessica Loriena" <jloriena@hotpop.com> wrote in message
    > news:9beb2b43.0307292113.3defdc8e@posting.google.c om...
    > > I'm trying to write a simple "register form / validate and store in
    > > database / show welcome screen" application with ASP.Net. With
    > > conventional ASP, I used Session variables and it went something like
    > > this:
    > >
    > > *****
    > > form.asp
    > >
    > > - <form action="ValidateAndStore.asp" method="post">
    > >
    > > *****
    > > ValidateAndStore.asp
    > >
    > > - Pass form values into Session variables.
    > >
    > > - If validation OK Then
    > > Store in database
    > > redirect("welcome.asp")
    > > Else
    > > redirect("form.asp?error=ValidateError")
    > > End If
    > >
    > > *****
    > > welcome.asp
    > >
    > > - Show form values using previously stored Session variables
    > >
    > >
    > > I know there are no need for Session variables in ASP.Net forms
    > > because the state is preserved. All tutorials and books I've read so
    > > far show how to post ASP.Net forms to itself (post back), but how do I
    > > validate and redirect to *another* page without losing the form
    > > variables??? Do I have to use Session variables again even with
    > > ASP.Net forms??
    >
    >

    Kevin Spencer Guest

  5. #4

    Default Re: New to ASP.Net forms (and Session variables??)

    Does anyone have a comment on my approach for using ASP.Net forms and
    page redirecting below?



    [email]jloriena@hotpop.com[/email] (Jessica Loriena) wrote in message news:<9beb2b43.0307302001.71292a9@posting.google.c om>...
    > So, from I understood, the best approach for my problem in ASP.Net would be:
    >
    > *******
    > form.aspx
    >
    > If IsPostBack Then
    > If Validation is OK Then
    > Store form variables in Session variables
    > Store form variables in database
    > Response.Redirect("welcome.aspx")
    > End If
    > End If
    >
    > <form runat="server">
    > ...
    > </form>
    >
    >
    > *******
    > welcome.aspx
    >
    > - Show form values using previously stored Session variables
    >
    >
    > Please correct me if I'm wrong, or if there's a better way...
    >
    > Thanks for your replies!
    >
    >
    > > >
    > > > "Jessica Loriena" <jloriena@hotpop.com> wrote in message
    > > > news:9beb2b43.0307292113.3defdc8e@posting.google.c om...
    > > > > I'm trying to write a simple "register form / validate and store in
    > > > > database / show welcome screen" application with ASP.Net. With
    > > > > conventional ASP, I used Session variables and it went something like
    > > > > this:
    > > > >
    > > > > *****
    > > > > form.asp
    > > > >
    > > > > - <form action="ValidateAndStore.asp" method="post">
    > > > >
    > > > > *****
    > > > > ValidateAndStore.asp
    > > > >
    > > > > - Pass form values into Session variables.
    > > > >
    > > > > - If validation OK Then
    > > > > Store in database
    > > > > redirect("welcome.asp")
    > > > > Else
    > > > > redirect("form.asp?error=ValidateError")
    > > > > End If
    > > > >
    > > > > *****
    > > > > welcome.asp
    > > > >
    > > > > - Show form values using previously stored Session variables
    > > > >
    > > > >
    > > > > I know there are no need for Session variables in ASP.Net forms
    > > > > because the state is preserved. All tutorials and books I've read so
    > > > > far show how to post ASP.Net forms to itself (post back), but how do I
    > > > > validate and redirect to *another* page without losing the form
    > > > > variables??? Do I have to use Session variables again even with
    > > > > ASP.Net forms??
    > > >
    > > >
    Jessica Loriena Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139