Wahrscheinlich nicht das, was Sie suchen, aber warum nicht jQuery verwenden, um die Datei hochzuladen? Sie können jQuery Form Plugin verwenden, um es zu tun. Dies ist das Skript:
<script type="text/javascript" src="Scripts/jquery-1.4.1.min.js"></script>
<script type="text/javascript" src="Scripts/jquery.form.js"></script>
<script type="text/javascript">
$("#myForm").ajaxForm({
success: function (response) {
$('#updateDiv').append(response);
}
});
</script>
Und das ist die HTML:
<form id="myForm" action="http://localhost/Default.aspx" method="post"
enctype="multipart/form-data">
<div id="updateDiv" runat="server">
</div>
<div>
<input type="file" id="filePhoto" name="filePhoto" value="" />
<input type="submit" value="Upload Photo" />
</div>
</form>
Natürlich haben Sie die Formular-Vorlage in Ihrem Code-behind zu handhaben und die entsprechende Antwort zurückschicken.
funktioniert perfekt – jinsungy