Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

AjaxFileUpload to access ViewState problem.

$
0
0

I have a page having a button and an AjaxFileUpload control. Each time I click the button, I save some value into ViewState, and when I upload files, I want to use the ViewState I saved, however, during the AjaxFileUpload1_UploadComplete events, no save ViewState could be found.

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
            }
            return;
        }
        protected void AjaxFileUpload1_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
        {
            int test = (int)ViewState["test"];
            //... other codes
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            ViewState["test"] = 1;
        }



I use VS debug tool, after I click the button1, each time the page postback, I could get the value of ViewState["test"], however, when I upload some files, and click "upload" during that postback, ViewState["test"] is null. If I click other button (not button1) to postback after I upload files, the ViewState["test"] value is back to normal.

If I just put the ViewState["test"]=1 in Page_Load If(!IsPostBack) block, during AjaxFileUpload1_UploadComplete event, it can find the ViewState["test"].

But how can I get ViewState set in postback stage?


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>