Monday 27 August 2012

Difference between Response.Redirect , Server.Transfer

asp.net | Response.Redirect |  Server.Transfer method using program code source

Asp.net supports only one form  at the server side.
Redirection page:-if we want  to navigate from one page to another
page we have to use following method.
1)Response.Redirect
2)Server.Transfer

create new form in asp.net
craete a new asp.net website from the solution explorer and add new

item for web.Form

page Load:-

Response.Redirect ();

-we can find destination file name  at the url i.e

this file displaying by the browser destination.

Server Transfer:-
this file is displaying by the web server because of this  we can not find
destination file name at the url.


using System;

public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write("we are in new page");
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Text = "asp.net event programming";


}
protected void Button2_Click(object sender, EventArgs e)
{
//Response.Redirect("default1.aspx");
Server.Transfer("default2.aspx");
}
}
1) run this program with help of two button and one text box
2) when you will click on button 1 then message will come on text box

and if you will click on the button 2 then it will give msg on page load .
i.e "we are in new page ".
when click on button one then

TextBox1.Text = "asp.net event programming"; this will work

means "asp.net event programming"; this msg will appear in the text

box 1.
3) if  you will execeute both then problem comes in

//Response.Redirect("default1.aspx"); this line.

we wrote there on page load msg will come on screen it means it
transfer same msg using Server transfer. asfter click on button 2 it will
give msg what we have seen on page load.

well something for work?
find out meaning of this line.....
object sender, EventArgs e?
Share This
Previous Post
Next Post

FYJC XI standard online admisson Process and declaraton of Merit list . Cut off List For prevous year also . 10 Th Results onlne declaraton Maharashtra Region .

0 comments: