什么时候可以安全地禁用viewstate? [英] When is safe to disable viewstate?

查看:78
本文介绍了什么时候可以安全地禁用viewstate?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

何时可以安全地禁用viewstate?对于哪些控件?在什么情况下?

When is safe to disable viewstate? For which controls? Under what circumstances?

在用户控件中,我已禁用viewstate,但是如果我尝试单击此控件,则

In a user control I have disabled viewstate, but if I attempt to click in this control

<asp:LinkButton ID="LinkButton1" runat="server" 
  CommandName="Delete" 
  OnClientClick="return confirm('¿Está seguro que desea eliminar el mensaje?');"
  EnableViewState="true">
    <asp:Image ID="ImageButton1" runat="server" ImageUrl="~/Content/Images/delete.png" 
        ToolTip="Eliminar mensaje" /> Eliminar 
</asp:LinkButton>

我收到一个System.InvalidOperationException异常.它在ListView内部.

I get an System.InvalidOperationException exception. It is inside a ListView.

推荐答案

在禁用viewstate的情况下,大多数控件的行为都与您期望的一样.带有Gridviews等内置功能的更具动态性"的控件在没有viewstate的情况下往往无法正常播放.

Most controls behave as you would expect with viewstate disabled. The more 'dynamic' controls with built in functionality like Gridviews tend not to play well without viewstate.

如果您已将控件上的enableviewstate属性设置为true,那么您是否确定异常与viewstate相关?

Are you sure that the exception is related to the viewstate given that you have the enableviewstate property set to true on your control?

这篇关于什么时候可以安全地禁用viewstate?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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