且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在ASP.NET中将两个ID从一个页面传递到另一个页面

更新时间:2023-01-08 12:41:37

最简单干净的方法是将这些字段值作为查询字符串发送到URL中。我假设您从order.aspx打开print.aspx页面。



例如print.aspx?TableId = {TableIdValue}& TableSeatId = {TableSeatIdValue}



此URL可以在服务器和客户端(JS)上创建。
The simplest and clean way is to send these field values as query strings in URL. I assume you are opening print.aspx page from order.aspx.

e.g. print.aspx?TableId={TableIdValue}&TableSeatId={TableSeatIdValue}

This URL can be created on server as well as client side (JS).


您可以将ID存储在会话变量中,然后在任何地方调用它!



You could store the ID inside a Session Variable and then call it wherever you want!

var Id1;
var Id2;
Session["FirstID"] = Id1;
Session["SecondID"] = Id2;



如果您想在另一页上打电话,那么您就这样做了:




If you would like to call it then on another page then you siply do this:

var GetID1 = Convert.ToInt32(Session["FirstID"]);
var GetID2 = Convert.ToInt32(Session["SecondID"]);





这些值将从Session中检索并放入GetID1,GetID2变量..



我希望这可以帮到你!



The values will be retrieved from the Session and put inside GetID1,GetID2 Variables..

I hope this helps you out!