473,756 Members | 1,818 Online
Bytes | Software Development & Data Engineering Community
+ 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 1601
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*@discussion s.microsoft.com > wrote in message
news:88******** *************** ***********@mic rosoft.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(objec t sender, System.EventArg s 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(o bject sender, System.EventArg s e)
{
Server.Transfer ("Webform2.aspx ");
}

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

private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
if (!IsPostBack)
{
WebForm1 sourcepage = (WebForm1) Context.Handler ;
Label1.Text = sourcepage.Prop erty1;
}
}

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

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.Button1.Cl ick += new System.EventHan dler(this.Butto n1_Click);
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

private void Button1_Click(o bject sender, System.EventArg s 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*@discussion s.microsoft.com > wrote in message
news:88******** *************** ***********@mic rosoft.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(objec t sender, System.EventArg s 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(o bject sender, System.EventArg s e)
{
Server.Transfer ("Webform2.aspx ");
}

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

private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
if (!IsPostBack)
{
WebForm1 sourcepage = (WebForm1) Context.Handler ;
Label1.Text = sourcepage.Prop erty1;
}
}

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

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.Button1.Cl ick += new System.EventHan dler(this.Butto n1_Click);
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

private void Button1_Click(o bject sender, System.EventArg s 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*@discussion s.microsoft.com > wrote in message
news:88******** *************** ***********@mic rosoft.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.I tems("myParamet er"),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*@discussion s.microsoft.com > wrote in message
news:88******** *************** ***********@mic rosoft.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
5942
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 contains: <?php $_SESSION = ""; $_SESSION = "";
1
7786
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: ---------------------------------------------------------------------------- <?php ini_set("session.use_cookies", "off"); ini_set("session.use_trans_sid", "on"); session_start(); $_SESSION = ""; $_SESSION = ""; echo "<form method='POST' action='login.php'>
5
7613
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 the array is needed ratherthan idividual reference. The situation is like this: When the page is loaded based on the user input say 6 values are created like character1="tom", character2="jerry", Character3="micky", Character4="donald",...
1
4614
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: http://www.dslextreme.com/users/kevinlyons/selectResults.html I am passing name, email, countries, cities, products, courses, etc. The others display as they should on the subsequent page,
11
2114
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 = Server.CreateObject("ADODB.Connection") DSNtest="DRIVER={Microsoft Access Driver (*.mdb)}; " DSNtest=dsntest & "DBQ=" & Server.MapPath("ncci.mdb") Conn.Open DSNtest
1
2275
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 page of the form post all answers in clean ?= format as though all form elements were from one page. I use GET to pass name/value pairs from the first to the second page because no JS is needed to use Get once, and then I use a single hidden
28
3128
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 program. is this a valid concern? i'm thinking i can check the submitting page setting up something around the following the following code... $base_name = basename($_SERVER);
1
2857
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 issue is that all of my dropdown menus are passing the last row to the next page as the session variable. The pages that I am talking about can be found at: Weekly13_Test The code that follows was operational until the change. Here is my...
13
8696
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 frame 2 submenu seletion now i want to have value to be passed between the pages on frame3 based on submenu selection in frame 2
5
10300
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 may also open up new chat windows with other members (just not the same one). - Each chat page is opened with the member name as the window name. - When I log off from the web page, I would like all the chat windows to automatically close. I...
0
9456
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10034
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6534
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3805
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 we have to send another system
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.