473,473 Members | 1,483 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Passing value between pages

gkr
Hi

I would like to pass values/data from Page1 to Page 2, then capture values
on page 2 and return back to Page 1 with the values from page2. Can you pls
guide me on how to do this ?

I tried Server.transfer to pass values from Page1 to Page2, but from page2
am unable to return to Page 1 or any other page with the values picked from
Page2.

Thanks
gkr
Nov 19 '05 #1
4 1586
This might be a bit old skool but in my current project I need to store the
state of a menu while a user is on another page so it can be rebuilt when
they return.

I am using Text Boxes to store the values I want, then I on the receiving
page I can use Request.Form["ItemID"] to get the values, I can easly check
if there are any values by looking for the empty string. This is simple fast
and bullet proof + I make the texboxes invisible through CSS but it is easy
to remove the style and see eaxctly which values are being passed - handy in
some situations.
Of course the nice way of doing it is by using getters for the transmitting
page, then you can you use Context.Handler to try and cast the transmitting
page in the receiving page and access its values via its getters. You may
need to use a try catch clause with this in case the user hasnt visiting the
transmitting page. ITs all covered far more eliqently and completely in the
article below. Good luck and i were you id go for the getter approach :)
http://www.codeproject.com/aspnet/TransferingValues.asp
"gkr" <gk*@discussions.microsoft.com> wrote in message
news:88**********************************@microsof t.com...
Hi

I would like to pass values/data from Page1 to Page 2, then capture values
on page 2 and return back to Page 1 with the values from page2. Can you pls guide me on how to do this ?

I tried Server.transfer to pass values from Page1 to Page2, but from page2
am unable to return to Page 1 or any other page with the values picked from Page2.

Thanks
gkr

Nov 19 '05 #2
gkr
Hi Stephen

I tried the Get property but facing issues when trying to return control
from Page to Page 1. Am not sure what is going wrong.

The scenario that I would like to create is
Page 1 click button --> pass values --> Page 2 (capture passed value)
Page 2 click button --> pass values --> Page 1 (capture passed value)

Attached below is the code snippet that I am using :
WebForm1.aspx ( PAGE 1)
public string Property1
{
get
{
return TextBox1.Text;
}
}

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!IsPostBack)
{
}
else
{
WebForm2 wf2 = (WebForm2) Context.Handler;
Label1.Text = wf2.Property2;
}
}
private void Button1_Click(object sender, System.EventArgs e)
{
Server.Transfer("Webform2.aspx");
}

WebForm2.aspx ( PAGE 2)
public string Property2
{
get
{
return Label1.Text;
}
}

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!IsPostBack)
{
WebForm1 sourcepage = (WebForm1) Context.Handler;
Label1.Text = sourcepage.Property1;
}
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void Button1_Click(object sender, System.EventArgs e)
{
Server.Transfer("Webform1.aspx",true);
}

The above code worked fine when I navigate from Page 1 to Page 2, but when
it tries to navigate back to page1 - it fails !

Can you pls help ?

Thanks
"Stephen Adam" wrote:
This might be a bit old skool but in my current project I need to store the
state of a menu while a user is on another page so it can be rebuilt when
they return.

I am using Text Boxes to store the values I want, then I on the receiving
page I can use Request.Form["ItemID"] to get the values, I can easly check
if there are any values by looking for the empty string. This is simple fast
and bullet proof + I make the texboxes invisible through CSS but it is easy
to remove the style and see eaxctly which values are being passed - handy in
some situations.
Of course the nice way of doing it is by using getters for the transmitting
page, then you can you use Context.Handler to try and cast the transmitting
page in the receiving page and access its values via its getters. You may
need to use a try catch clause with this in case the user hasnt visiting the
transmitting page. ITs all covered far more eliqently and completely in the
article below. Good luck and i were you id go for the getter approach :)
http://www.codeproject.com/aspnet/TransferingValues.asp
"gkr" <gk*@discussions.microsoft.com> wrote in message
news:88**********************************@microsof t.com...
Hi

I would like to pass values/data from Page1 to Page 2, then capture values
on page 2 and return back to Page 1 with the values from page2. Can you

pls
guide me on how to do this ?

I tried Server.transfer to pass values from Page1 to Page2, but from page2
am unable to return to Page 1 or any other page with the values picked

from
Page2.

Thanks
gkr


Nov 19 '05 #3
gkr
Hi Stephen

I tried the Get property but facing issues when trying to return control
from Page to Page 1. Am not sure what is going wrong.

The scenario that I would like to create is
Page 1 click button --> pass values --> Page 2 (capture passed value)
Page 2 click button --> pass values --> Page 1 (capture passed value)

Attached below is the code snippet that I am using :
WebForm1.aspx ( PAGE 1)
public string Property1
{
get
{
return TextBox1.Text;
}
}

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!IsPostBack)
{
}
else
{
WebForm2 wf2 = (WebForm2) Context.Handler;
Label1.Text = wf2.Property2;
}
}
private void Button1_Click(object sender, System.EventArgs e)
{
Server.Transfer("Webform2.aspx");
}

WebForm2.aspx ( PAGE 2)
public string Property2
{
get
{
return Label1.Text;
}
}

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (!IsPostBack)
{
WebForm1 sourcepage = (WebForm1) Context.Handler;
Label1.Text = sourcepage.Property1;
}
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

private void Button1_Click(object sender, System.EventArgs e)
{
Server.Transfer("Webform1.aspx",true);
}
The above code worked fine when I navigate from Page 1 to Page 2, but when
it tries to navigate back to page1 - it fails !

Can you pls help ?

Thanks

"Stephen Adam" wrote:
This might be a bit old skool but in my current project I need to store the
state of a menu while a user is on another page so it can be rebuilt when
they return.

I am using Text Boxes to store the values I want, then I on the receiving
page I can use Request.Form["ItemID"] to get the values, I can easly check
if there are any values by looking for the empty string. This is simple fast
and bullet proof + I make the texboxes invisible through CSS but it is easy
to remove the style and see eaxctly which values are being passed - handy in
some situations.
Of course the nice way of doing it is by using getters for the transmitting
page, then you can you use Context.Handler to try and cast the transmitting
page in the receiving page and access its values via its getters. You may
need to use a try catch clause with this in case the user hasnt visiting the
transmitting page. ITs all covered far more eliqently and completely in the
article below. Good luck and i were you id go for the getter approach :)
http://www.codeproject.com/aspnet/TransferingValues.asp
"gkr" <gk*@discussions.microsoft.com> wrote in message
news:88**********************************@microsof t.com...
Hi

I would like to pass values/data from Page1 to Page 2, then capture values
on page 2 and return back to Page 1 with the values from page2. Can you

pls
guide me on how to do this ?

I tried Server.transfer to pass values from Page1 to Page2, but from page2
am unable to return to Page 1 or any other page with the values picked

from
Page2.

Thanks
gkr


Nov 19 '05 #4
Here's a nice, simple way to pass values from one page to another:
(VB.NET code)

'Add data to the context object before transferring
Context.Items("myParameter") = x
Server.Transfer("WebForm2.aspx")

Then, in WebForm2.aspx:

'Grab data from the context property
Dim x as Integer = CType(Context.Items("myParameter"),Integer)

Of course there are a number of ways to pass values from one page to
another, such as using the querystring, cookies, session,
context, saving to a temporary table in the database between each page, etc.
You'll have to decide which technique is best for your application.
Here are several good articles on the subject to help you decide.
http://msdn.microsoft.com/msdnmag/is...e/default.aspx

http://www.aspalliance.com/kenc/passval.aspx

http://www.dotnetbips.com/displayarticle.aspx?id=79

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"gkr" <gk*@discussions.microsoft.com> wrote in message
news:88**********************************@microsof t.com...
Hi

I would like to pass values/data from Page1 to Page 2, then capture values
on page 2 and return back to Page 1 with the values from page2. Can you
pls
guide me on how to do this ?

I tried Server.transfer to pass values from Page1 to Page2, but from page2
am unable to return to Page 1 or any other page with the values picked
from
Page2.

Thanks
gkr

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul | last post by:
I want to use sessions to cover myself in case the user switches off cookies so I am passing the session ID manually through a hidden input field. This is what I have so far. index.php page...
1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
5
by: Raju V.K | last post by:
I am developing a web site which requires a set og unique values be transferred between pages and server many times. There fore i decided to put the values in an array so that only one reference to...
1
by: Kevin Lyons | last post by:
Hello, I am trying to get all of my form elements passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html to the following URL:...
11
by: Dthmtlgod | last post by:
I am having a little difficulty in passing a value from a page to another page. I am going to provide excerpts from the code. I think I am close. This is from Page1.ASP <% Set Conn =...
1
by: williamroy | last post by:
Hello, I've got a form that runs over 5 pages. I need the last page submit button to post all of the answers at one time from the previous 5 pages (to another server). I'd like to see the last...
28
by: Skeets | last post by:
i'm passing session and hidden variables between pages. not to mention post values. i'm a little concerned that someone with sufficient knowledge could spoof these vlaues and manipulate the...
1
SHOverine
by: SHOverine | last post by:
Recently my web host decided to "upgrade". This change rendered many of my pages useless and I am scrambling to fix the issues, so you may see several posts from me in the coming days. My first...
13
by: sindhu | last post by:
Hello acoder. I want to know another type of passing values between pages I have three frames frame1 for main horizontal menu frame 2 for vertical submenu frame 3 which is is loaded based on...
5
by: aelred | last post by:
I have a web page where a member can open up a chat window (child window) with another member. - From there the member can also navigate to other web pages. - From other pages in the site, they...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.