gpt4 book ai didi

asp.net - 为什么 __VIEWSTATE 隐藏输入元素被
包围?

转载 作者:行者123 更新时间:2023-12-04 08:27:48 24 4
gpt4 key购买 nike

为什么ASP.NET 渲染隐藏__VIEWSTATE <div></div>内的输入元素?

最佳答案

他们这样做是为了“更加符合 Web 标准”——这是 MSDN 杂志文章 Enforce Web Standards For Better Accessibility 中的引述。 :

There were some well-known deficiencies in ASP.NET 1.1. The out-of-the-box controls produced code that would not pass validation. That was largely attributed to the way that ViewState was handled in ASP.NET 1.1-using a hidden input tag that was not contained within a block display, like this:

<input type="hidden" name="__VIEWSTATE" value="dDwtMTU1NzQzNDgy..." />

This, combined with some other syntactical issues, gave ASP.NET 1.1 an unfortunate reputation for non-compliance.
ASP.NET 2.0 addressed many of the Web standards issues. For example, if you look at the source of ASP.NET 2.0-generated pages, you see that ViewState is now wrapped in a div tag, making it compliant:

<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="dDwtMTU1NzQzNDgy..." />
</div>

Microsoft has made it known publicly that one of the goals of ASP.NET 2.0 is to be more aligned with Web standards and, in fact, ASP.NET 2.0 lets you create compliant Web sites and controls. A great resource for building compliant Web sites is Stephen Walther's MSDN® article "Building ASP.NET 2.0 Web Sites Using Web Standards". This 78-page article goes into great detail on building sites according to Web standards.



这是否真的更符合 Web 标准是公开辩论的个人我对 Web 标准还不够深入,无法发表自己的意见,我只是回答你的问题。

关于asp.net - 为什么 __VIEWSTATE 隐藏输入元素被 <div></div> 包围?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11599329/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com