I've used PreviousPage Property to access the controls of the previous page but how can I access objects and instances of classes I initiated in the previous page!
我已经使用PreviousPage属性来访问上一页的控件,但是如何访问我在上一页中启动的对象和类的实例!
Thanks For Your Time =)!
谢谢你的时间=)!
2 个解决方案
#1
4
You can cast the PreviousPage object to the type of the previous page if it exposes public properties and methods that are going to be of use to you. However this isn't the same instance of the page that you created during the previous request. Any properties of then page that you set during the previous request will no longer be set.
如果PreviousPage对象公开了对您有用的公共属性和方法,则可以将PreviousPage对象强制转换为上一页的类型。但是,这与您在上一个请求期间创建的页面的实例不同。将不再设置您在上一个请求期间设置的页面的任何属性。
One of the downsides to the webforms model is it encourages you to think that web programming preserves state from one request to the next, when in fact it doesn't.
webforms模型的缺点之一是它鼓励您认为Web编程保留了从一个请求到下一个请求的状态,而事实上并非如此。
#2
2
Unless you persisted the state of the objects, etc. from the previous page then they are gone.
除非您从上一页继续保持对象等的状态,否则它们就会消失。
#1
4
You can cast the PreviousPage object to the type of the previous page if it exposes public properties and methods that are going to be of use to you. However this isn't the same instance of the page that you created during the previous request. Any properties of then page that you set during the previous request will no longer be set.
如果PreviousPage对象公开了对您有用的公共属性和方法,则可以将PreviousPage对象强制转换为上一页的类型。但是,这与您在上一个请求期间创建的页面的实例不同。将不再设置您在上一个请求期间设置的页面的任何属性。
One of the downsides to the webforms model is it encourages you to think that web programming preserves state from one request to the next, when in fact it doesn't.
webforms模型的缺点之一是它鼓励您认为Web编程保留了从一个请求到下一个请求的状态,而事实上并非如此。
#2
2
Unless you persisted the state of the objects, etc. from the previous page then they are gone.
除非您从上一页继续保持对象等的状态,否则它们就会消失。