开发者

viewstate not work and not disable it

开发者 https://www.devze.com 2023-04-02 04:49 出处:网络
property curRefID: public string curRefID { get { returnViewState [\"curid\"] as string; } set { ViewState [\"curid\"] = value;
property curRefID:

   public string curRefID
    {
        get
        {
            return  ViewState ["curid"] as string;
        }
        set
        {
            ViewState ["curid"] = value;
        }
开发者_运维技巧    }

I init it in method InitUCControl()

   protected override void OnInit ( EventArgs e )
        {
            base.OnInit ( e );
            if ( !IsPostBack )
            {
                InitUCControl ( );
            }
        }

and then i want use the property in a button click event, it always return null. but it had a value when i debug it in InitUCControl(). I don't know why it can't work...so weird. ps:I didn't disable viewstate .in page's html source code viewstate can be found.


According to MSDN viewstate isn't available in OnInit event, try PreLoad event instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消