Я загружаю изображение с помощью JQuery AjaxUpload и пытался обновить управление изображением с этим загруженным изображением, но код не работает, даже не удается установить ViewState. Я хочу знать, почему это происходит. Ниже код:
**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>
fileupload.aspx.cs Код
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" не обновляется?