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

编程入门 行业动态 更新时间:2024-10-27 22:34:05
本文介绍了如何在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.

更多推荐

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

本文发布于:2023-11-03 06:21:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1554434.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实例   页面   如何在   NET   ASP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!