ViewState中或HiddenField [英] ViewState or HiddenField

查看:194
本文介绍了ViewState中或HiddenField的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个简单的数据块存储(例如一个整数或字符串)我可能会选择存储在ViewState中,或使用HiddenField控件。

If I have a simple piece of data to store (an integer or string for example) I might choose to store that in ViewState, or using a HiddenField control.

为什么我会选择一个比其他?

Why would I choose one over the other?

的ViewState

ViewState


  • 硬盘,为用户解除code(认为不是不可能的),这可能是可取

HiddenField

HiddenField


  • 值可以在JavaScript中使用

还有其他的优点和缺点是什么?

Are there other pros and cons?

推荐答案

不是真的,ViewState的实际存储在一个隐藏字段所以唯一的真正的区别是编码。

Not really, ViewState is actually stored in a hidden field so the only real difference is the encoding.

除非你需要操作使用JavaScript的价值或你希望关闭的ViewState此页面上共有然后我会使用的ViewState。大多只是因为有第三方工具(像这样的)的理解和ViewState中赢得不懂您的自定义隐藏字段。

Unless you need to manipulate the value with JavaScript or you hope to turn off ViewState on this page altogether then I'd use ViewState. Mostly just because there are third party tools (like this one) which understand ViewState and which won't understand your custom hidden field.

这篇关于ViewState中或HiddenField的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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