Click here to Skip to main content
15,891,833 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

How to pass values from one page to another page via java script?
Posted

C#
Using QueryString you can Pass value to the other page
function move() {
window.location = 'newPage.aspx?PageId=23';
}
 
Share this answer
 
Comments
Raj kumar.C 7-Mar-12 6:31am    
Is possible to pass values from one page to another page without query string?
You can do it by HiddenFields.

Follow these links to help you:

Link1[^]
Link 2[^]
Link 3[^]

In ASP.Net you can also use Session Variables[^], QueryStrings[^] or Cookies[^] to pass variables between pages.

Good luck,
OI
 
Share this answer
 
Comments
Tech Code Freak 8-Mar-12 3:46am    
5up!
Orcun Iyigun 8-Apr-12 16:13pm    
thanks.
Monjurul Habib 8-Apr-12 12:18pm    
5!
Orcun Iyigun 8-Apr-12 16:13pm    
thanks.
In my opinion, this is not a very good idea, especially if you use ASP.NET anyway.

The thing is: HTTP protocol is stateless. All the data entered in one page is totally lost when you load a different page. So, you need to store some data in between, but JavaScript has limited access to storage. You can store data in cookies though (please see http://www.w3schools.com/js/js_cookies.asp[^]), but there is a better, safer way.

You are using ASP.NET. Instead of using JavaScript, you can use session state in ASP.NET.

I would advise to start here:
http://msdn.microsoft.com/en-us/library/ms178581.aspx[^].

Also see this article: http://msdn.microsoft.com/en-us/magazine/cc301579.aspx[^].

This is a good FAQ page on the topic: http://www.eggheadcafe.com/tutorials/aspnet/c3e1fc0b-3ea0-4955-af1e-2c052a55cd23/aspnet-session-how-to-faqs.aspx[^]

—SA
 
Share this answer
 
v3
Comments
Monjurul Habib 8-Apr-12 12:17pm    
5!
Sergey Alexandrovich Kryukov 8-Apr-12 22:51pm    
Thank you, Monjurul.
--SA
You may use
Query Strings
Cookies
Session variables
Server.Transfer
Post Back URL


Passing data/parameters/values from one aspx page to another aspx page[^]
Passing Values from One Page to Another Page – ASP.NET[^]
 
Share this answer
 
Comments
Espen Harlinn 8-Apr-12 6:58am    
5'ed!
Monjurul Habib 8-Apr-12 12:17pm    
5!
VJ Reddy 8-Apr-12 20:53pm    
+5
You can use Query Strings[^] to pass values from one page to another. And then if you want to get the value in javascript, you may refer to this link[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900