如何在这种情况下将数据从页面传递到页面? [英] How to pass data from page to page like in this case?

查看:99
本文介绍了如何在这种情况下将数据从页面传递到页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们说我有两个页面,一个页面用户将选择未知的学生,每个学生有两个属性字符串名称和数组成绩。如何将学生数据全部传递到另一个页面。

所以如果用户选择3名学生,则第二页获取学生数据。每个学生和他的成绩。

Lets say I have two pages, one page where user will choose unknown of students, each student has two properties string name and array grades. how can I pass the student data to another page all to together.
So If the user choose 3 students, the second page to get the students data. Each student and his grade.

推荐答案

你究竟是怎么做的将取决于各种各样的事情,包括你如何为所有学生实际存储信息,而不仅仅是您的三个用户感兴趣,但基本机制是相同的。有三种基本方法:

1)查询字符串。网址可以包含问号右侧的其他信息:您可能已经看到过多次使用Google查询等等:

Exactly how you do that will depend on a huge variety of things, including how you actually store the information for all students, not just the three your user is interested in, but the basic mechanism is the same. There are three basic ways to do it:
1) Query string. URL's can contain additional information, to the right of a question mark: you've probably seen it loads of times with Google queries and so forth:
mydomain.com/mypage.apsx?key=value

将它们重定向到第二页时可以使用相同的东西。然后页面访问查询字符串并找到学生列表。

2)Cookies。您可以将信息发送到客户端,并将其存储在他的计算机上。第二页然后在页面加载期间访问cookie并显示学生信息。

3)会话。这存储在服务器上,第二页直接访问它以获取相关学生。



每个都有优点和缺点,但你需要一个他们。如果您只是快速搜索,谷歌可以找到使用它们的确切方法。



错别字[/ edit]

You can use the same thing when you redirect them to the second page. The page then accesses the query string and finds the list of students.
2) Cookies. You can send the information to the client and it's stored on his computer. The second page then access the cookies during page Load and displays the student info.
3) Session. This is stored on the server and the second page accesses it directly to fetch the relevant students.

There are advantages and disadvantages to each, but you'll need one of them. Google can find you the exact way to use them if you just search quickly.

[edit]Typos[/edit]


这篇关于如何在这种情况下将数据从页面传递到页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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