PC Review


Reply
Thread Tools Rate Thread

button_Click event and Request.Redirect

 
 
Jason Huang
Guest
Posts: n/a
 
      7th Jun 2007
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


 
Reply With Quote
 
 
 
 
PlatinumBay
Guest
Posts: n/a
 
      7th Jun 2007
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

"Jason Huang" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Dimitar Voynov
Guest
Posts: n/a
 
      12th Jun 2007
PlatinumBay wrote:
> 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
>
> "Jason Huang" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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
>>
>>

>
>

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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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
Update a user control after Button_Click event Winshent Microsoft ASP .NET 1 17th Oct 2005 02:12 PM
asp.net C# Button_click event and javascript function Jason Huang Microsoft C# .NET 0 21st Jun 2005 09:59 AM
Q: button_click event does not work =?Utf-8?B?SklNLkgu?= Microsoft ASP .NET 3 6th Apr 2005 03:45 PM
Getting the Button_Click Event before Page_Load? Frank Schumacher Microsoft ASP .NET 2 16th Nov 2004 12:00 PM
Re: labels and button_click event Mike Kitchen Microsoft C# .NET 0 14th Sep 2004 09:23 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:48 PM.