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

ContextKeys and ViewState Not Available on Async Postback - AjaxFileUpload Control

$
0
0

I added an AjaxFileUpload control on my own Web User Control.  I haven't added any update panels or anything else to the page.  It doesn't even have a MasterPage.  So, in the PageLoad event, I set my AjaxFileUpload control's ContextKey property to unique ID (a GUID) and a viewstate property with the name of that GUID and set its value to 'test'.

When I upload the files, my codebehind handler fires successfully, and I try to extract the contextkeys info and it is 'nothing'.  ViewState on UploadComplete is also 'nothing'.  I have enabled viewstate in my page, web user control, and the AjaxFileUpload control for giggles (even though I think it is on by default), and I still don't get back my values.  If i enter the ContextKeys property in HTML (static), then on postback the ContextKeys property is set, but again its static and not very helpful.

Funny enough, session state is available to me through out the process.  While this is good, it is also bad (not going to help me).  I understand that this is Asynchronous and that my viewstate might be blank, but after evaluating the JavaScript after a page render, it appears that they are accounting for this and are copying the ViewState into a variable called;

<Control_Name>_<AjaxFileUpload_Name>_ClientState eg. in my Test1 web user control mine is 'Test1_AjaxFileUpload1_ClientState'

So, my questions are; Is there a bug here, or

  1. Will ViewState not be available to me?
  2. Can I not programatically set the ContextKeys and use it during the Async Postback?

Let me tell you what I am trying to do, so you know why this is important.  I want to track their uploads and refresh an update panel so the number of files uploaded is incremented.  I also want to display a modal popup on completion on the client side when all files have been uploaded, and show the user where their files were saved on the server (important if the files are copies and I had to rename them on the fly).  To make this extensible, I want the ability for a user to have multiple browser windows open and be uploading files with each browser independently.  If i used a common session state variable, then the two browswers would fight for use of that common variable, because they share session state; hence why I can't use session state.  If I used ViewState, then the info would be independent of each other and it would work just fine.

Any help would be appreciated. Thanks in advance. - Jon


Viewing all articles
Browse latest Browse all 5678

Trending Articles



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