c# - Persisting variable after AsyncFileUpload call to OnUploadedComplete -


this strange one. have ajax toolkit file uploader called asyncfileupload located in update panel. asyncfileupload control, put file there, begins upload , calls server. store file blob , obtain row id database table using select @@identity. far good, have row id , wish store it. placed inside hidden field when asyncfileupload calls onclientuploadcomplete, hidden field blank! thought "okay, i'll store in viewstate". surprise, same thing happened; viewstate gets cleared. had success using session variable. question is, why session variable work , viewstate or hiddenfield not?

front:

<script type="text/javascript">     function uploadcomplete(sender, args) {         var filesize = args.get_length();         if (filesize > 2000000) {             alert("logo size must smaller 2mb");         }          $("[id*=hfuploadsuccessful]").val("1");         //calls postback , lvmembers_prerender gets executed results         __dopostback('<%=updatepanel1.clientid %>', null);     } </script>                                      <div id="divclassfileupload">                                         <asp:asyncfileupload id="asyncfileupload1" runat="server" width="350" cssclass="fileuploadclass floatleft"                                             uploaderstyle="modern"                                             completebackcolor="lime"                                             errorbackcolor="red"                                             throbberid="throbber"                                             uploadingbackcolor="#66ccff"                                             onclientuploaderror="uploaderror"                                              onclientuploadstarted="startupload"                                             onclientuploadcomplete="uploadcomplete"                                             onuploadedcomplete="asyncfileupload1_uploadedcomplete" />                                     </div> 

back:

    protected void asyncfileupload1_uploadedcomplete(object sender, ajaxcontroltoolkit.asyncfileuploadeventargs e)     {              //hfselectedarticleid.value = dt.rows[0]["articleid"].tostring());             //viewstate.add("articleid", dt.rows[0]["articleid"].tostring());             session.add("articleid", dt.rows[0]["articleid"].tostring());          } 

edit: found similar post sort of explains it. thank everyone! not getting value in viewstate in asp.net using c#?


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -