I am using Ajax AsyncFileUpload
in asp.net
. It is working fine in uploading image but don't know why it is redirecting to same page with some querystring OnUploadComplete
. I don't want to reload page. How to solve this ?
My Code is as below:
function uploadComplete() {
document.getElementById('<%=lblPhotoUpload.ClientID %>').innerHTML = "Quiz Image Uploaded Successfully.";
$("#UploadQuizImageProcess").hide();
}
function uploadError() {
document.getElementById('<%=lblPhotoUpload.ClientID %>').innerHTML = "File Upload Failed.";
$("#UploadQuizImageProcess").hide();
}
function uploadQuizImageStart() {
$("#UploadQuizImageProcess").show();
}
<asp:AsyncFileUpload ID="fuPhoto" runat="server" UploadingBackColor="#779ED3" CompleteBackColor="#179406" ThrobberID="imgLoad" OnUploadedComplete="QuizImageUploadComplete" OnClientUploadStarted="uploadQuizImageStart" OnClientUploadComplete="uploadComplete" OnClientUploadError="uploadError" UploaderStyle="Traditional" />
<span id="UploadQuizImageProcess" style="display: none">
<img src="../images/uploading.gif" alt="Upload" /></span>
<asp:Label ID="lblPhotoUpload" runat="server" CssClass="lbler"></asp:Label>
protected void QuizImageUploadComplete(object sender, AsyncFileUploadEventArgs e)
{
if (fuPhoto.HasFile)
{
string filename = "";
filename = "quiz" + ".jpg";
// Save Image
}
}
is it not per design in asp.net webforms, that a post goes allways back to the same page ?
In your case it goes then in the QuizImageUploadComplete method. So you could do a response.redirect("someulr.aspx") at the end of this method to get to another page
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With