Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does not redirect page after UploadComplete in AsyncFileUpload c#

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
        }
    }
like image 610
Jeeten Parmar Avatar asked May 23 '15 12:05

Jeeten Parmar


1 Answers

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

like image 108
Stefan Wuthrich - Altafino Avatar answered Nov 15 '22 06:11

Stefan Wuthrich - Altafino