Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Response.write is not working inside of update panel

$
0
0

Hi, I want to open a file using c# by clicking a button where button in updatepanel, after opening the file i want to commit some data to the database. For this i have taken button which is in updatepanel and response.write commands. However after executingthese lines its not committing any data to the database. For this i have taken button which is in updatepanel and Response commands. However after executing these lines its not committing any data to the database. my aspx page looks like

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><asp:UpdatePanel ID="UpdatePanel1" runat="server"><ContentTemplate><asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /><asp:Label ID="Label1" runat="server" Text=""></asp:Label></ContentTemplate><Triggers><asp:PostBackTrigger ControlID="Button1" /></Triggers></asp:UpdatePanel>

 and my cs file Button1_Click contains

Label1.Text += "File Opening...";


            Response.Buffer = true;
            Response.Clear();
            Response.AppendHeader("Content-Type", "text/plain");
            Response.AppendHeader("Content-disposition", "attachment; filename=147.txt");
            FileStream sourceFile = new FileStream("D:\\147_1.txt", FileMode.Open);
            long FileSize;
            FileSize = sourceFile.Length;
            byte[] getContent = new byte[(int)FileSize];
            sourceFile.Read(getContent, 0, (int)sourceFile.Length);
            sourceFile.Close();
            Response.BinaryWrite(getContent);
            Response.Flush();
            System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest();
            Response.Close();

Label1.Text+="File Opened...";

 

In the above code nothing of text label1.text displayed or any other data committing to database.

Please help me on committing data to database after executing Response commands which opens a file.

Thanks in advance.


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>