Passing Value from one page to another page

There is three more way to transfer value (rather then request.querystring or response.redirect) from one page to another…Check it out…

Default.aspx

These Code Written on Button Click

string str = txt.Text;

1) // By Context we could pass the value to one page to another

Context.Items.Add(“name”,str);

Server.Transfer(“JQueryPage.aspx”);

2) //By Session

Session["name"] = str;

3) //This is a new feature in asp.net2.0, In this term I went to the property of button and

set the postbackurl= “~/JQueryPage.aspx”

Then after I went to the JqueryPage and find the textbox control “txt” which I created in my root page so based on it I got my value directly

In the JqueryPage

We can Transfer Data From One Page to Another Page

JQueryPage.aspx

This code written on Page Load

1) // By Context

string sessionval = Context.Items["name"].ToString();

txt.Text = sessionval;

2) // This is By Session

string sessionval= Session["name"].ToString();

txt.Text = sessionval;

3) // By Previous PAge

TextBox txt1 = (TextBox)PreviousPage.FindControl(“txt”);

txt.Text = txt1.Text;

Advertisement

2 Responses to “Passing Value from one page to another page”

  1. A nice article…

  2. Quite useful!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.