Balwinder Pal
Balwinder Pal

Reputation: 97

How to pass value from web form to another web form?

Can anybody tell me how to pass a value from one web form to another web form without using a query string and session?

Upvotes: 2

Views: 6834

Answers (7)

Kadir
Kadir

Reputation: 3224

With Session:

For example you login the system and your id is 123123123.

string userid = 123123123; 


Session["userid"] = userid;

When you go another page/pages your session is alive when your session timeout.

<system.web>
    <sessionState timeout="1250"/>
</system.web>

Upvotes: 1

aldo_t
aldo_t

Reputation: 1

depends on type and how much information you wish to transfer. for instance, if you want to transfer some variable (strings or integer values) you consider to use querystring (you can found here major information). for instance, if you want to transfer typed objects (class instance) you consider to use session (you can found here major information).

Upvotes: 0

Shashank Jain
Shashank Jain

Reputation: 89

Using PostBackURL, ex:

PostBackUrl="~/result.aspx"

and on result.cs (Page Load)

lblEmployeeNumber.Text = HttpContext.Current.Request.Form["txtEmployeeNumber"];

Upvotes: 2

Arjan Tijms
Arjan Tijms

Reputation: 38163

It seems what you're looking for is something like the flash-, view- or conversation scope in Java EE and Ruby on Rails.

For ASP.NET you could perhaps take a look at this one: Is there an equivalent of JSF @ViewScope in ASP MVC?

Upvotes: 0

Chamika Sandamal
Chamika Sandamal

Reputation: 24302

there are several ways you can pass parameters between pages.

  1. Using a Query String
  2. Getting Post Information from the Source Page
  3. Using Session State
  4. Getting Public Property Values from the Source Page
  5. Getting Control Information from the Source Page in the Same Application

for more detail visit followng link.

http://msdn.microsoft.com/en-us/library/6c3yckfw.aspx

Upvotes: 3

NaveenBhat
NaveenBhat

Reputation: 3328

You can pass the Values over different pages via QueryString like:

Response.Redirect("yourNextpage.aspx?identifier=DesiredValue");

On your next page you can retrieve the value like this:

Request.QueryString["identifier"];

Other Preferred way would be Server.Transer() and Postbackurl.

Refer this link for various possible ways.

Upvotes: 4

Evan
Evan

Reputation: 1737

You could use a Querystring in this case:

Page.Response.Redirect("show.aspx?id=1");

And then read it on the other end:

int id = Page.Request.QueryString["id"];

Upvotes: 2

Related Questions