Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 2.15 KB  |  hits: 21  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Server controls not updated after JQuery AjaxUpload
  2. **Javascript:**<br>
  3. <script type="text/javascript">    /*<![CDATA[*/<br>
  4.         $(document).ready(function() {<br>
  5.             /* Example 1 */<br>
  6.             var button = $('#button1'), interval;<br>
  7.             new AjaxUpload(button, {<br>
  8.                 action: 'fileupload.aspx',<br>
  9.                 name: 'myfile',<br>
  10.                 onSubmit: function(file, ext) {<br>
  11.                     // change button text, when user selects file<br>
  12.                     button.text('Uploading');<br>
  13.                     // If you want to allow uploading only 1 file at time,<br>
  14.                     // you can disable upload button<br>
  15.                     // this.disable();<br>
  16.                     // Uploding -> Uploading. -> Uploading...<br>
  17.                     interval = window.setInterval(function() {<br>
  18.                         var text = button.text();<br>
  19.                         if (text.length < 13) {<br>
  20.                             button.text(text + '.');<br>
  21.                         } else {<br>
  22.                             button.text('Uploading');<br>
  23.                         }<br>
  24.                     }, 200);<br>
  25.                 },<br>
  26.                 onComplete: function(file, response) {<br>
  27.                     button.text('Upload');<br>
  28.                     window.clearInterval(interval);<br>
  29.                     // enable upload button<br>
  30.                     this.enable();<br>
  31.                     // add file to the list<br>
  32.                     $('<li></li>').appendTo('#example1 .files').text(file);<br>
  33. //                    document.getElementById('img').src = 'C:\Documents and <br>Settings\Kavita\My Documents\Visual Studio 2008\WebSites\WebSite2\ajaxUpload\' + file;<br>
  34. //                    alert(document.getElementById('img').src);<br>
  35.                 }<br>
  36.             });<br>
  37.         });   /*]]>*/</script><br><br>
  38.        
  39. HttpPostedFile hpfFile = Request.Files["myfile"];
  40.     if (hpfFile != null)
  41.     {
  42.        hpfFile.SaveAs(Server.MapPath("~/ajaxUpload/" + hpfFile.FileName));
  43.        img.Src = Server.MapPath("~/ajaxUpload/" + hpfFile.FileName);
  44.     }<br>
  45.        
  46. img.Src = "~/ajaxUpload/" + hpfFile.FileName;