开发者

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开发者_如何学JAVA using a query string and session?


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.


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


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"];


Using PostBackURL, ex:

PostBackUrl="~/result.aspx"

and on result.cs (Page Load)

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


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>


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?


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜