 |
| ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

July 7th, 2005, 12:32 PM
|
|
Authorized User
|
|
Join Date: Jun 2005
Posts: 32
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Passing variale from 1 form to another.
Is is possible to do it? Can anyone show me the way? thanks
|
|

July 7th, 2005, 01:13 PM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
Place the variable into a session variable.
|
|

July 8th, 2005, 06:03 AM
|
|
Authorized User
|
|
Join Date: Feb 2005
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
In asp.net if u want to pass a variable from one page to another page it is better to use response.redirect method or sessions or cookies.
using response.redirect
response.redirect("page2.aspx?var1="<value of variable such as textbox1.text or 56>)
in page 2 use the following code to retrive the value
if request.querystring("var1")="" then
'checking for null value
response.redirect("page1.aspx")
else
variable2=request.querystring("var1")
endif
now the value you passed from page 1 is in variable2
ok same way u can use session variables also
in page1.aspx
session("var1")=textbox1.text or "56"
in page2.aspx
variable2=session("var1")
'now variable2 contains the value
i am not good at cookies so i am not mentioning here.
Hope this Helps-Ashok Parchuri
|
|

July 8th, 2005, 09:22 AM
|
|
Friend of Wrox
|
|
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
|
|
As Ashok stated, cookies are also an option, but that depends on your application, internet or intranet, persistance of cookies. However for simplicity, his examples will work fine.
|
|

July 8th, 2005, 12:25 PM
|
|
Authorized User
|
|
Join Date: Jun 2005
Posts: 32
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Thanks a lot ashokparchuri..It works great with the session variable.
|
|

July 9th, 2005, 11:56 AM
|
|
Authorized User
|
|
Join Date: Jun 2005
Posts: 32
Thanks: 0
Thanked 1 Time in 1 Post
|
|
i try the response.redirect as taught by but it can't work? is it missing out something like "?the code is as following as following
response.redirect("page2.aspx?var1="<value of variable such as textbox1.text or 56>)
|
|

July 9th, 2005, 01:26 PM
|
 |
Friend of Wrox
|
|
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
|
|
You need to construct the redirect string yourself... he was providing an example:
response.redirect("page2.aspx?var1=" & variableThatContainsMyValueForVar1)
- Peter
|
|

July 12th, 2005, 02:27 AM
|
|
Authorized User
|
|
Join Date: Feb 2005
Posts: 91
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Oh...
I am really very sorry to for got the &symbol.any way i hope you finished your work...
-Ashok Parchuri
|
|

August 4th, 2005, 10:46 AM
|
|
Authorized User
|
|
Join Date: Jun 2005
Posts: 32
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Thanks Ashok Parchuri and planoie..I have fix it...a late coming thanks... 
|
|

August 17th, 2005, 12:53 AM
|
|
Registered User
|
|
Join Date: Jun 2005
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
why you are using response.redirectand all...to passing the values from one page to other pages..
because it doesnt provide security to our data right,..
what my suggestion is use the Context.Handler object.
simply you create object for that form in someother form and get the values.thats it.
if i am wrong pls corrcet me..?????
thanks
rams123
|
|
 |