I am opening some Panel having a some code like this
<td rowspan="2">
<br />
<asp:UpdatePanel ID="updatePnl" runat="server">
<ContentTemplate>
<asp:LinkButton ID="lnkYurLevel" runat="server" ForeColor="#009999" Text="What are my next steps?"
Font-Size="Medium" OnClick="lnkYurLevel_Click"></asp:LinkButton>
</ContentTemplate>
</asp:UpdatePanel>
</td>
protected void lnkYurLevel_Click(object sender, EventArgs e)
{
if (lblFileName.Text != "")
{
string path = Server.MapPath(@"~\downloads\" + lblFileName.Text);
System.IO.FileInfo file = new System.IO.FileInfo(path);
if (file.Exists)
{
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "application/octet-stream";
Response.WriteFile(file.FullName);
Response.End();
}
else
{
Response.Write("This file does not exist.");
}
}
}
and on button click i am opening a file that is to be download but that download don’t appear, as it was working when not kept in panel that is to be open through model pop up.
Now when it is placed in a panel that is to be open through model pop up. it doesn’t work.
What is the reason?
An action inside the
UpdatePanelwon’t change the wholeResponse, just a part of the page. So you cannot expectResponse.Writeto work. The alternative is to make the button force a fullPostBackAdd a
PostBackTriggerto theasp:Buttonlike thisor if you want to do that in code-behind, do this.