You are on page 1of 5

1) Response.

Redirect (single parameter)

Default.aspx

protected void Button1_Click(object sender, EventArgs e)


{
Response.Redirect("login.aspx?acno=" + TextBox1.Text);
}

Login.aspx

Drag and drop lable1

public partial class login : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Request["acno"];
}
}

2. Change the code as(passing 2 values as parameter[multiple parameters] how


to handel it?)

Drag and drop TextBox2 and write following code in Button1_Click()….

Default.aspx

protected void Button1_Click(object sender, EventArgs e)


{
Response.Redirect("login.aspx?acno=" +TextBox1.Text+"&aname="+TextBox2.Text);
}
Login.aspx code is

protected void Page_Load(object sender, EventArgs e)


{
Label1.Text = Request["acno"]+"---"+Request["aname"];
}

The url is http://localhost:7813/multiformhandiling1/login.aspx?


acno=1&aname=san

(url changes in Request.Response method but doesnot changes when we use


Server.Transfer()—output is same)

2) Request.Response(url)

Eg: Response.Redirect("http://www.google.com");
Summary of Request.Response()

a)From source page:

1. Request.Response(<pagename>)
2. Request.Response(url)
3. Request.Response(qury)

Eg1:Response.Redirect("login.aspx?acno=" + TextBox1.Text);
Eg2 : Response.Redirect("login.aspx?acno="
+TextBox1.Text+"&aname="+TextBox2.Text);

b) the values coming form sourcepage is handled in distination page when


parameter is sent in the format of Request.Response(qury)using the key word
Request[“parameter name”]

[Eg1:Response.Redirect("login.aspx?acno=" + TextBox1.Text);
Eg2 : Response.Redirect("login.aspx?acno="
+TextBox1.Text+"&aname="+TextBox2.Text);]

2. Server.Transfer();

Default.aspx.cs

protected void Button1_Click(object sender, EventArgs e)


{
Server.Transfer("login.aspx", true);
//Response.Redirect("login.aspx?acno=" +
TextBox1.Text+"&aname="+TextBox2.Text);
}

Login.aspx.cs(drag and drop Lable1)

public partial class login : System.Web.UI.Page


{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Request["TextBox1"]+"---"+Request["TextBox2"];
// Label1.Text = Request["acno"]+"---"+Request["aname"];
}
}

url: http://localhost:7813/multiformhandiling1/Default.aspx

url: http://localhost:7813/multiformhandiling1/Default.aspx

before clicking button (sending request to server’s url) the url is same of
after sending and getting response form server ie no change in url

Summary of Request.Response()

a)From source page:

1. Server.Transfer (“<pagename>”,true)

Eg: Server.Transfer("login.aspx", true);

How to handle the parameters coming form source page ?

Writ the handling code for source page in distination page as follows

Eg:
Page_Load()//login.aspx

Label1.Text = Request["TextBox1"]+"---"+Request["TextBox2"];

TextBox1 and TextBox2 are the textboxes of default.aspx sourcepage utilised as


it is in distination login.aspx page

You might also like