简体   繁体   English

使用javascript将值从一页传递到另一页

[英]Pass value from one page to another using javascript

I have two pages as Parent.aspx and Child.aspx in my asp.net web application. 我在asp.net Web应用程序中有两个页面,如Parent.aspx和Child.aspx。 The values obtained from parent.aspx need to pass to child.aspx code behind page. 从parent.aspx获得的值需要传递给页面后面的child.aspx代码。

The redirect from parent to child happens through javascript. 从父级到子级的重定向通过javascript进行。 Parent page contains empId which needs to be passed to child page code behind file as the same ID could be used to fetch the details of the employee such as name, age, PIN, bank account details etc. 父页面包含empId,该文件需要传递到文件后面的子页面代码,因为可以使用相同的ID来获取员工的详细信息,例如姓名,年龄,PIN,银行帐户详细信息等。

How to do the same? 怎么做呢?

thanks! 谢谢!

Check out ASP.NET QueryString Usage or any other resources on ASP.NET Query String access. 在ASP.NET查询字符串访问中检查ASP.NET QueryString的用法或任何其他资源。 A full example follows. 下面是一个完整的示例。

On the client side: 在客户端:

window.open ("http://www.yourwebsite.com?empid=somethin&PIN=somethinglese","mywindow");

On the server side (in code behind): 在服务器端(在后面的代码中):

string empid;
string PIN;

if(Request.QueryString.Count != 0)
{
    empid = Request.QueryString["empid"];
    PIN = Request.QueryString["PIN"];
}

Why not using a session or something similar? 为什么不使用会话或类似方法?

Then in the page load event of ur child page , check that session if not null, then retrieve the data. 然后在您的子页面的页面加载事件中,检查该会话是否不为null,然后检索数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM