button_Click event and Request.Redirect

  • Thread starter Thread starter Jason Huang
  • Start date Start date
J

Jason Huang

Hi,

In my .Net 2.0 C# web form Form1, say I have a button btnToForm2.
Is the Request.Redirect("Form2") the right way to go to the Form2 in the
btnToForm2_Click event?
Actually, I also want to pass a parameter from the Form1 to Form2, do I need
to declare a global variable for storing?
Thanks for help.


Jason
 
Jason,

You have a couple options:

You can call set the variables in the session state, and call
Response.Redirect to send the browser to the new page.

You can call Server.Transfer and the context will apply to the new page.

You can call Response.Redirect and pass the parameters in the querystring.

Hope this helps,


Steve
 
PlatinumBay said:
Jason,

You have a couple options:

You can call set the variables in the session state, and call
Response.Redirect to send the browser to the new page.

You can call Server.Transfer and the context will apply to the new page.

You can call Response.Redirect and pass the parameters in the querystring.

Hope this helps,


Steve
Hello.

I agree with Steve.

Just keep in mind these considerations when deciding which of the three
approaches to use.
1. About storing variables in the session - it is good approach if using
just variables. If you plan to store some objects like tables and so on,
you should not forget about the overhead this is going to cause (thus
probably delaying your application execution time).
2. About the Server.Transfer method. Since the way this method works you
won't be able to click the "back" button and return to the first form.
That's why I don't like this approach.
3. Passing your variables in the query string is fine if they are
meaningless. I mean that choosing to pass information in this way
everyone would be able to see it, since everyone is able to see the
connection string.

Greetings!

Dimitar V.
 
Back
Top