Note that there are some explanatory texts on larger screens.

plurals
  1. POajax calls not being made after doPostBack
    text
    copied!<p>I am making the users download a file on an anchor tag click. On its onclick event, i have used __doPostBack to partial post back the page to return the file which is downloadable by the user. </p> <p>Now the problem i am facing is, that when the file is not found, the page reloads and the ajax calls are not set. So, in short, when the browser is expecting a response after _doPostBack function, and does not get one, it reloads the page but $.ajax methods do not run. What am i missing? Should I do something with the response? or is there any way that the response can be cancelled? Please help.</p> <p>The anchor tag is, for instance </p> <pre><code>&lt;a onclick="javascript:__doPostBack('AnnouncementAttachmentDownload','Ch 7 -Software Design2010.doc')"&gt;Ch 7 -Software Design2010.doc&lt;/a&gt; </code></pre> <p>The server side code is</p> <pre><code>protected void Page_Load(object sender, EventArgs e) { SetPageTitles(ModuleNames.NotSpecified, null, false, true, true, false); if (this.Request.Params["__EVENTTARGET"] == "AnnouncementAttachmentDownload") { string FileName = this.Request.Params["__EVENTARGUMENT"].ToString(); string destinationPath = Server.MapPath("~/" + System.Web.Configuration.WebConfigurationManager.AppSettings["AnnouncementAttachmentsPath"]).ToString() + "\\"; if (System.IO.File.Exists(destinationPath + FileName)) { Response.AppendHeader("content-disposition", "attachment; filename=" + FileName); Response.TransmitFile(destinationPath + FileName); Response.End(); } else { ClientScript.RegisterClientScriptBlock(this.GetType(), "NewScript", "alert('The requested file could not be found, please contact portal.production.support');", true);\\DOESNT WORK } } } </code></pre> <p>The line in the else part, it just shows the message but the page loads after that too.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload