如何在ASP.NET中创建页面实例

问题描述:

如何在第二页中创建第一页的实例以访问第一页的属性

how to create instance of firstpage in secondpage to access properties of firstpage

我们无法做到这一点.但是您可以使用Session或QueryString对象将数据从一页传递到另一页.

例如

在第一页上

We cannot do that. But you can use Session or QueryString objects to pass data from one page to other page.

e.g.

on Page one

Page_Load()
{
      Session["one"] = "1234";
}


重定向到第二页

在第二页


redirect to page two

On Page Two

Page_Load()
{
      lable1.Text = Session["one"].ToString();
}


我建​​议阅读ASP.NET上的一本书.似乎您不知道它或网络的工作方式.您可以使用跨页回发来启动第二页,以便它可以访问第一页中的值.您还可以将两个页面编写为控件,将它们托管在一页上,然后在后面的代码中访问它们的存储值,在这种情况下,将是存储它们的viewstate.如前所述,会话或查询字符串也是可能的解决方案.
I suggest reading a book on ASP.NET. It seems like you have no idea how it, or the web, works. You CAN use a cross page postback to launch the second page so that it has access to values from the first page. You can also write the two pages as controls, host them on the one page, and then access their stored values in your code behind, in which case it would be viewstate that stores them. As has been said, the session or the query string are also possible solutions.