1

What is the difference in utility/performance between using PersistenceMode on a property and storing the value of said property in ViewState in an ASP.NET web page?

This:

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
    [PersistenceMode(PersistenceMode.InnerProperty)]
    public int ClientUno { get; private set; }

versus this:

    public int ClientUno
    {
        get
        {
            if (ViewState["ClientUno"] == null) return 0;
            else return (int)(ViewState["ClientUno"]);
        }
        set { ViewState["ClientUno"] = value; }
    }

I have done some googling around the internets and can't figure this one out. It seems like this would have come up before - I just can't find the answer. Anyone?

4

1 回答 1

1

PersistanceMode与将数据存储在ViewState. 它用于创建自定义服务器控件并影响服务器代码。例如,请参阅:如何在 ASP.Net 中使用子控件集合制作控件

于 2012-11-08T20:22:49.333 回答