为什么视图状态只能包含序列化对象? [英] Why Viewstate can contain only serializable object?

查看:167
本文介绍了为什么视图状态只能包含序列化对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些属性和其他数据的简单类。直到我坚持序列化的属性类的,我不能在类的对象保存到视图状态。

I have a simple class with some properties and other data. Untill i stick serializable attribute to the class, i cannot save the object of the class into the viewstate.

为什么视图状态只能包含序列化对象?

Why Viewstate can contain only serializable objects?

推荐答案

作为请求的视图状态传递回浏览器嵌入生成的网页的HTML代码中的序列化再presentation这是有道理的,只有serialisable对象可以放置在它(否则它可能无法重新present在它的内蕴。)这视图状态,然后在下一个请求期间反序列化。

As the viewstate of a request is passed back to the browser as a serialised representation embedded within the generated page's HTML it makes sense that only serialisable objects can be placed within it (otherwise it may fail to represent that which it contains.) That viewstate is then de-serialised during the next request.

如果您使用的是POCO的将其标记为serialisable应该足够简单。有关于如何理解作品的ViewState一个很好的资源,它是什么等在这里:

If you are using POCO's marking them as serialisable should be trivial enough. There is an excellent resource on understanding how viewstate works, what it is etc. here:

<一个href=\"http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx\">http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx

它进入状态的整个生命周期,并提供了有关很多它的实施和使用从前瞻性开发的细节。

It goes into the full lifecycle of the state and gives detail about much of it's implementation and use from the prospective of a developer.

这篇关于为什么视图状态只能包含序列化对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆