通过javascript传递值 [英] Pass values through javascript

查看:54
本文介绍了通过javascript传递值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如何通过Java脚本将值从一页传递到另一页?

Hi,

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

推荐答案

Using QueryString you can Pass value to the other page
function move() {
window.location = 'newPage.aspx?PageId=23';
}


您可以通过HiddenFields做到.

请通过以下链接为您提供帮助:

Link1 [链接2 [链接3 [ ^ ]

在ASP.Net中,您还可以使用会话变量 [查询字符串 [ Cookies [ ^ ]通过页面之间的变量.

祝你好运,
OI
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


在我看来,这不是一个好主意,尤其是如果您仍然使用ASP.NET的话.

问题是:HTTP协议是无状态的.当您加载另一页时,一页中输入的所有数据都将完全丢失.因此,您需要在两者之间存储一些数据,但是JavaScript对存储的访问受到限制.不过,您可以将数据存储在Cookie中(请参阅 http://www.w3schools.com/js/js_cookies.asp [ ^ ]),但有一个更好,更安全的方法方式.

您正在使用ASP.NET.代替使用JavaScript,可以在ASP.NET中使用会话状态.

我建议从这里开始:
http://msdn.microsoft.com/en-us/library/ms178581.aspx [ ^ ].

另请参阅本文: http://msdn.microsoft.com/en-us/magazine/cc301579.aspx [ ^ ].

这是关于该主题的很好的FAQ页面:
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


这篇关于通过javascript传递值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆