- Server controls not updated after JQuery AjaxUpload
- **Javascript:**<br>
- <script type="text/javascript"> /*<![CDATA[*/<br>
- $(document).ready(function() {<br>
- /* Example 1 */<br>
- var button = $('#button1'), interval;<br>
- new AjaxUpload(button, {<br>
- action: 'fileupload.aspx',<br>
- name: 'myfile',<br>
- onSubmit: function(file, ext) {<br>
- // change button text, when user selects file<br>
- button.text('Uploading');<br>
- // If you want to allow uploading only 1 file at time,<br>
- // you can disable upload button<br>
- // this.disable();<br>
- // Uploding -> Uploading. -> Uploading...<br>
- interval = window.setInterval(function() {<br>
- var text = button.text();<br>
- if (text.length < 13) {<br>
- button.text(text + '.');<br>
- } else {<br>
- button.text('Uploading');<br>
- }<br>
- }, 200);<br>
- },<br>
- onComplete: function(file, response) {<br>
- button.text('Upload');<br>
- window.clearInterval(interval);<br>
- // enable upload button<br>
- this.enable();<br>
- // add file to the list<br>
- $('<li></li>').appendTo('#example1 .files').text(file);<br>
- // document.getElementById('img').src = 'C:\Documents and <br>Settings\Kavita\My Documents\Visual Studio 2008\WebSites\WebSite2\ajaxUpload\' + file;<br>
- // alert(document.getElementById('img').src);<br>
- }<br>
- });<br>
- }); /*]]>*/</script><br><br>
- HttpPostedFile hpfFile = Request.Files["myfile"];
- if (hpfFile != null)
- {
- hpfFile.SaveAs(Server.MapPath("~/ajaxUpload/" + hpfFile.FileName));
- img.Src = Server.MapPath("~/ajaxUpload/" + hpfFile.FileName);
- }<br>
- img.Src = "~/ajaxUpload/" + hpfFile.FileName;