Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0 ASP.NET
Hi Friends,
On a button click event, I am calling File save dialogue box.
After saving the file, I want to refresh the radgrid.
When I try with RadGrid.Rebind() method, it calls the NeedDatasource event of the grid with no problem.
I can see updated values in object. But I cannot see those updated values in grid.
I need to refresh the page.
So to refresh the page, I called " this.Page_Load(null, null); "
but no luck.
I have to hit F5 button to refresh the page.
 
If I remove the code to call Save File Dialogue box, it works perfectly.
There is something wrong with the response of the page.
 
Could you please help me out?
 
This is my code :
protected void btnPayment_Click(object sender, EventArgs e)
{
  try
     {
         // Perform some actions...
         
 
// This code below calls the Save File Dialogue box..

String FilePath = Server.MapPath(".\\GiroPayments\\" + FileName + "");
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.Clear();
response.ContentType = "text/plain";
response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + ";");
response.TransmitFile(FilePath);
response.Flush();
response.End();
 
rgGiroPayments.Rebind();
this.Page_Load(null, null);
 
     }
catch()
{}
}
Posted 1-Jul-12 22:58pm
Comments
Sandeep Mewara at 2-Jul-12 6:36am
   
You do a Response.End and thus the code after it is not getting executed.
LokeshZende at 2-Jul-12 6:38am
   
yes sandip, thats the reason. Any solution for it?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

hi
 
follow the code
 
if (!Page.IsPostBack)
        {
            //page will be refereshed at a interval of 10 sec
            Response.AddHeader("Refresh", "10");
        }
  Permalink  
Comments
LokeshZende at 2-Jul-12 5:16am
   
It works only till FileSave Dialogue box opens.
Once I save the file, nothing happens.Page doesn't refresh.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

There is no way out for this situation.
Once response ends, we cannot get another response as there is only one response to one request.
So I added another button on the form, on click of which, it will refresh my page.
User HAS TO click the button in order to refresh the page.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I would suggest to you to do the file download functionality in an iFrame / a popup so that you can work in the main page after downloading the file also, so when you do
 
Response.End();
 
It only ends the Response object of the iFrame/popup so that it doesn't ends the main Response Object
 

Mark it as solution if it answer your question
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 259
1 Sergey Alexandrovich Kryukov 182
2 Hard_Rockz 153
3 Richard MacCutchan 125
4 Maciej Los 104
0 OriginalGriff 5,374
1 Sergey Alexandrovich Kryukov 4,713
2 Peter Leow 2,944
3 DamithSL 2,465
4 Maciej Los 2,270


Advertise | Privacy | Mobile
Web01 | 2.8.140718.1 | Last Updated 3 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid