Pass value from one page to another using javascri

2019-09-01 04:03发布

I have two pages as Parent.aspx and Child.aspx in my asp.net web application. The values obtained from parent.aspx need to pass to child.aspx code behind page.

The redirect from parent to child happens through 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.

How to do the same?

thanks!

2条回答
可以哭但决不认输i
2楼-- · 2019-09-01 04:35

Check out ASP.NET QueryString Usage or any other resources on ASP.NET Query String access. 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"];
}
查看更多
乱世女痞
3楼-- · 2019-09-01 04:46

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.

查看更多
登录 后发表回答